2012-10-06 119 views
2

我在我的電腦上使用WAMP,並在編寫我的網站時,我決定刪除.html擴展名,以期提高美學效果。WAMP - 拖尾斜線(/)給出錯誤500「內部服務器錯誤」 - .htaccess錯誤?

這工作正常,所以,在我的情況下,temp.jakegriffin.co.uk/index.html成爲/索引,這是我想要的。不幸的是,如果有一個尾隨/索引之後,我得到:

Internal Server Error 

The server encountered an internal error or misconfiguration and was unable to complete  your request. 

Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error. 

More information about this error may be available in the server error log. 

當我嘗試在.htaccess文件來解決這個問題,我要麼得到錯誤403是我禁止或錯誤404人的頁面不存在。

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.html -f 
RewriteRule ^(.*)$ $1.html 

這是我用於去除擴展的.htaccess文件的代碼。如果有人可以幫助我,這將不勝感激。

在此先感謝, 傑克。

+0

什麼呢Apache的錯誤日誌說..? –

回答

0

這此的mod_rewrite規則:

* http://planetozh.com/blog/2004/05/apache-and-the-trailing-slash-problem/ 

    RewriteEngine on 
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} -d 
    RewriteRule ^(.+[^/])$ $1/ 
+0

這也沒有效果。當沒有結尾的斜線時,它只會導致404錯誤。但是,當沒有結尾的斜線時,它會起作用。 – user1725807

+0

好的 - 請試試這個:http://stackoverflow.com/questions/10245542/trailing-slashes-causing-error-code-500 – paulsm4

0

試試這個:

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.html -f 
RewriteRule ^(.+)[\/*]$ $1.html [L,NC] 

現在你可以index之後添加了一堆正斜槓(/)的;)

+0

不,沒有用。當沒有結尾的斜線時,它只會導致404錯誤。但是,當沒有結尾的斜線時,它會起作用。 – user1725807

相關問題