最近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 重新加載)