APACHE支援.htaccess偽靜重寫出錯 No input file specified的解決方案_Linux

來源:互聯網
上載者:User

在你的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 OnRewriteBase /RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.*)$ /index.php/$1 [L]

而提示是說:“No input file specified.”,也就是說沒有得到有效檔案路徑。在Google中找到瞭解決方案,就是修改一下偽靜態規則,如下:

RewriteEngine OnRewriteBase /RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.*)$ /index.php?/$1 [L]

在正則結果“$1”前面多加了一個“?”號,問題也就隨之解決了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.