当前位置: 移动技术网 > 网络运营>服务器>Linux > APACHE支持.htaccess伪静重写出错 No input file specified的解决方案

APACHE支持.htaccess伪静重写出错 No input file specified的解决方案

2019年04月30日  | 移动技术网网络运营  | 我要评论

在你的apache安装文件夹conf里找到httpd.conf文件
搜索loadmodule rewrite_module modules/mod_rewrite.so 如果前面有注释符号#,请去掉。
搜索options followsymlinks,然后将它下面的allowoverride none 修改为allowoverride all;

【1】

没想到遇见了 no input file specified 因为项目用了url route ,估摸着可能是rewrite的问题。
记录一下解决方案。
1.检查doc_root 是否设置此值
2.检查.hta文件 , 很多框架都是index.php当入口文件。
默认的
rewriterule ^(.*)$ index.php/$1 [qsa,pt,l]
规则在apache fastcgi模式下会导致no input file specified.
修改成
rewriterule ^(.*)$ index.php [l,e=path_info:$1]
就ok,地址正常重写。

【2】

我们都知道,使用伪静态相对来说,对搜索引擎比较友好,而我在dreamhost的空间上启用rewrite的伪静态功能的时候,首页可以访问,而访问内页的时候,就提示:“no input file specified.”。
百度搜索了一下,发现还有其它空间商也有此问题,原因在于空间所使用的php是fast_cgi模式,而在某些情况下, 不能正确识别path_info所造成的错误,就是wordpress也有一样的问题,还好找到了解决方案!
我们首先来看一下wordpress及typecho等程序默认的.htaccess里面的规则:

rewriteengine on
rewritebase /
rewritecond %{request_filename} !-f
rewritecond %{request_filename} !-d
rewriterule ^(.*)$ /index.php/$1 [l]

而提示是说:“no input file specified.”,也就是说没有得到有效的文件路径。在google中找到了解决方案,就是修改一下伪静态规则,如下:

rewriteengine on
rewritebase /
rewritecond %{request_filename} !-f
rewritecond %{request_filename} !-d
rewriterule ^(.*)$ /index.php?/$1 [l]

在正则结果“$1”前面多加了一个“?”号,问题也就随之解决了。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网