No input file specified

我们都知道,使用伪静态相对来说,对搜索引擎比较友好,而我在Dreamhost的空间上启用REWRITE的伪静态功能的时候,首页可以访问,而访问内页的时候,就提示:“No input file specified.”。
百度搜索了一下,发现还有其它空间商也有此问题,原因在于空间所使用的PHP是cgi/fast_cgi模式[Server APIcgi/fast_cgi],xampp使用的是[Server API Apache 2.0 Handler(没毛病)],而在某些情况下,cgi/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”前面多加了一个“?”号,问题也就随之解决了。