2014-10-17 54 views
1

我遇到了一個小問題,我的.htaccess似乎無法修復它。將行添加到htaccess後,URL重寫失敗

RewriteEngine on 
# force ssl 

RewriteCond %{REQUEST_URI} !^/?(apps|user)/ 
RewriteRule ^5/(.*)/(.*).html$ /~ond/index.php?id=5&page=$1&titel=$2 
RewriteRule ^(.*)/(.*).html$ /~ond/index.php?id=$1&titel=$2 

上面的例子無瑕的作品與像一個URL:www.domain.com/123/title.html 不過,我想補充另一條規則:當我添加的代碼片段RewriteRule ^(.*)$ /~ond/index.php?id=$1 [L]

在我的htaccess的底部它將返回可能的內部服務器錯誤500.使用的URL:www.domain.com/This_Is_a_Test

我在做什麼錯了?這應該是一個非常小的問題。

謝謝。

回答

0

由於無限循環,它導致500服務器錯誤。通過保持RewriteCond僅允許非文件,非目錄請求來防止它:

RewriteEngine on 

RewriteCond %{REQUEST_URI} !^/?(apps|user)/ 
RewriteRule ^5/(.*)/(.*).html$ /~ond/index.php?id=5&page=$1&titel=$2 [L,QSA] 

RewriteRule ^(.*)/(.*).html$ /~ond/index.php?id=$1&titel=$2 [L,QSA] 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ /~ond/index.php?id=$1 [L,QSA] 
+0

非常感謝!你剛剛給我的星期一早晨開了個好頭。 – Jordy 2014-10-20 06:48:22

+0

不客氣,很高興它解決了。 – anubhava 2014-10-20 06:49:23