最近Annuo在开发API收费系统上线时及学习thinkphp5.1的过程中突然遇到此问题
也就是“ No input file specified”的报错错误;
如下图;
一遇到这问题一时就蒙圈了还以为是Apache 难道不靠谱了 哈哈..
好了下面来说正事;
方法/步骤;
提示:“No input file specified.”原因在于使用的PHP5.6是fast_cgi模式,而在某些情况下,不能正确识别path_info所造成的错误。默认的.htaccess里面的规则
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
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 -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
</IfModule>
仅仅就是在正则结果“/$1”前面多加了一个“?”号,问题也就解决了。
PS:用通常的过程启动 Apache(必须完全停止 Apache 再重新启动,而不是用 HUP 或者USR1 信号使 Apache 重新加载)