CodeIgniter框架隐藏index.php
Posted hnhycnlc888
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CodeIgniter框架隐藏index.php相关的知识,希望对你有一定的参考价值。
问题描述:使用CodeIgniter框架做项目时,在启用REWRITE的伪静态功能的时候,首页可以访问,但是访问其它页面的时候,就提示:“No input file specified.”
原因在于使用的php5.6是fast_cgi模式,而在某些情况下,不能正确识别path_info所造成的错误
默认的.htaccess里面的规则:
修改后的伪静态规则,如下:
原因在于使用的php5.6是fast_cgi模式,而在某些情况下,不能正确识别path_info所造成的错误
默认的.htaccess里面的规则:
IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] </IfModule>“No input file specified.”,是没有得到有效的文件路径造成的。
修改后的伪静态规则,如下:
IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L] </IfModule>仅仅就是在正则结果“/$1”前面多加了一个“?”号,问题也就随之解决了。
以上是关于CodeIgniter框架隐藏index.php的主要内容,如果未能解决你的问题,请参考以下文章
CodeIgniter - 如何从 URL 中隐藏 index.php
PHP框架CodeIgniter--URL去除index.php
php优秀框架codeigniter学习系列——index.php