Codeigniter URL后缀不起作用

时间:2016-08-24 20:34:11

标签: codeigniter web-config

我尝试了很多结果,即.html/作为网址后缀,但失败了。

我的config.php就像......

$config['base_url'] = 'http://localhost/domain/';
$config['index_page'] = 'index.php';
$config['uri_protocol'] = 'AUTO';
$config['url_suffix'] = '.html';

我的web.config就像......

<?xml version="1.0" encoding="UTF-8"?>
 <configuration>
  <system.webServer>
    <rewrite>
      <rules>
         <rule name="Clean URL" stopProcessing="true">
            <match url="^(.*)$" />
            <conditions>
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            </conditions>
            <action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" />
        </rule>
    </rules>
</rewrite> 

我的autoload.php就像......

$autoload['helper'] = array('url', 'file');

我的网址显示为......

http://localhost/domain/view_details/get/some_details

我希望网址像......

http://localhost/domain/view_details/get/some_details.html

我也尝试了thisthis,但失败了。

我该怎么办?

1 个答案:

答案 0 :(得分:2)

我没有看到您生成链接的任何代码。要生成链接,您应该使用site_url

来自你的config.php

echo site_url('test');
//will produce 
//http://localhost/domain/test.html

echo site_url('view_details/get/some_details');
//will produce 
//http://localhost/domain/view_details/get/some_details.html