apache出现no input file specified.的完美解决方案

启用rewrite的伪静态功能的时候,首页可以访问,而访问内页的时候,就提示:“No input file specified.”
原因在于使用的PHP是fast_cgi模式,而在某些情况下,不能正确识别path_info所造成的错误,Wordpress的伪静态也有一样的问题。

Wordpress程序默认的.htaccess里面的规则:

1
2
3
4
5
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

其实“No input file specified.”,是没有得到有效的文件路径造成的。修改伪静态规则,如下:

1
2
3
4
5
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

有没有发现不同?
其实就是在正则结果“/$1”前面多加了一个“?”号,问题也就随之解决了。

  • 作者: Sam
  • 发布时间: 2017-11-10 22:53:58
  • 最后更新: 2019-12-09 23:03:26
  • 文章链接: https://ydstudios.gitee.io/post/ff626742.html
  • 版权声明: 本网所有文章除特别声明外, 禁止未经授权转载,违者依法追究相关法律责任!