加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

解决CodeIgniter伪静态失效

发布时间:2020-12-12 20:13:10 所属栏目:PHP教程 来源:网络整理
导读:原来地址:http://127.0.0.1/onsite/index.php/welcome/index/abc123 修改后地址:http://127.0.0.1/onsite/abc123.html 代码如下: RewriteEngine on RewriteBase /onsiteRewriteCond %{REQUEST_URI} ^system.* RewriteRule ^(.*)$ /index.php?/$1 [L]Rewrit

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

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

代码如下:

RewriteEngine on
RewriteBase /onsiteRewriteCond %{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';

页面终于显示正常了;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读