当前位置:首页 > PHP教程 > PHP常见问题

解决CodeIgniter伪静态失效

原来地址:http://127.0.0.1/onsite/index.php/welcome/index/abc123

修改后地址:http://127.0.0.1/onsite/abc123.html

复制代码 代码如下:

<ifmodule mod_rewrite.c>
 rewriteengine on
 rewritebase /onsite

 rewritecond %{request_uri} ^system.*
        rewriterule ^(.*)$ /index.php?/$1 [l]

 rewritecond %{request_uri} ^application.*
        rewriterule ^(.*)$ /index.php?/$1 [l]

 rewritecond %{request_filename} !-f
 rewritecond %{request_filename} !-d
 rewriterule ^(.*).html$ index.php/welcome/index/$1 [l]
</ifmodule>

规则是没有错的,但万想不到codeigniter竟然报404找不到页面;经过测试在根目录建立同名的html文件是能够正常显示的;

那问题应该是ci的配置导致的;经过一番波折,发现一个参数:

复制代码 代码如下:

$config['uri_protocol'] = 'auto';

把它改成:

复制代码 代码如下:

$config['uri_protocol'] = 'path_info';

页面终于显示正常了;



【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!