>  기사  >  백엔드 개발  >  解决CodeIgniter伪静态失效_php实例

解决CodeIgniter伪静态失效_php实例

WBOY
WBOY원래의
2016-06-07 17:19:20886검색

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

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

复制代码 代码如下:


 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]

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

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

复制代码 代码如下:

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

把它改成:

复制代码 代码如下:

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

页面终于显示正常了;

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.