2011-08-25 148 views
1

我有這個網址http://xxxxxxxxx.com/account/session/login/redirect/%2Fhotel%2Frooms%2Findex%2Fhot_id%2F1它使用Zend Framework(PHP)。在.htaccess的幫助下錯誤報告404使用Apache(.htaccess重寫)

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-s 
RewriteCond %{REQUEST_FILENAME} !-l 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^.*$ index.php [NC,L] 

事情是我得到404未找到。爲了確保它是Apache,我退出了index.php主文件,當它啓動並且apache仍然報告404時。在退出之前沒有執行php的代碼。

編輯

我的域的阿帕奇domlog顯示此行

190.78.208.30 - - [25/Aug/2011:17:48:17 -0430] "GET /account/session/login/redirect/Fhotel%2Frooms%2Findex%2Fhot_id%2F1 HTTP/1.1" 404 25821 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0" 

但沒有在error_log中有關管線

EDIT 2

如果有用我運行Apache 2.2.19,PHP 5.3.6,cpanel 11.30.2,CentO小號5.6

Print screen of 404 Not found error

請注意404未找到。當我在執行其他任何事情之前退出index.php時,404仍然出現。我可以確定.htaccess正在被讀取。我推薦了一個

SetEnv MYENV 1 

並且顯示在同一個域中的phpinfo()中。我只是再次檢查我的access_log和error_log,並保持如上所述。

任何想法,爲什麼發生這種情況?

+1

錯誤日誌應該準確顯示apache嘗試爲該請求加載的文件/路徑。您也可以打開mod-rewrite調試,以確切瞭解事情如何被重寫。 –

+0

試試這個:RewriteEngine on RewriteRule!。(js | ico | gif | jpg | png | css)$ index.php – opHASnoNAME

回答

0

您確定您的.htaccess文件正在被Apache讀取嗎? 確保通過:

  1. 你有權在自己的網站目錄覆蓋值。有這個你應該有這樣的事情在你的Apache配置文件:

    <目錄/ var/www/html等>

    AllowOverride All 
    

    < /目錄>

    取代的/ var/WWW/html與您的網站公共目錄的路徑

  2. Apache有權讀取您的.hta訪問文件。

這樣Apache可以讀取並應用配置到您的.htaccess文件中。

爲了測試它,在你的.htaccess文件設置一個環境變量:

SetEnv MYENV 1 

,然後使用的phpinfo()函數在您的index.php文件,然後搜索環境變量。如果環境變量不在phpinfo()輸出中,則表示.htaccess文件未被Apache解析。