2010-01-12 51 views
0

使用這個重寫規則給我一個500.我的語法有什麼問題?mod_rewrite錯誤

Options +FollowSymlinks 
RewriteEngine on 
RewriteBase/
RewriteRule ^microsites/(.*)$ /microsites/index.php?uID=$1 [L] 

我想要做的就是靜靜地寫http://site.com/microsites/anythingatallhttp://site.com/microsites/index.php?uID=anythingatall

編輯:下面的作品,並且不拋出錯誤

RewriteRule ^([0-9])$ /microsites/index.php?uID=$1 [L] 

//結束編輯

感謝任何建議!

+0

rewrite.log說什麼? – 2010-01-12 18:28:40

+0

嗨泰勒,踢我添加了RewriteLog「/var/www/vhosts/site.com/rewrite.log」,但沒有記錄完成。似乎不太可能導致內部錯誤的htaccess能夠記錄該問題? – jerrygarciuh 2010-01-12 18:39:13

回答

1

錯誤在於microsites/index.php也匹配^microsites/(.*)$。排除你的目的地,它應該工作:

RewriteCond $1 !=index.php 
RewriteRule ^microsites/(.*)$ /microsites/index.php?uID=$1 [L] 
1

試試這個:

Options +FollowSymlinks 
RewriteEngine on 
RewriteBase /microsites/ 
RewriteRule ^(.*)$ /microsites/index.php?uID=$1 [L] 

它已經一段時間,但我相信你需要確保你的基地採取任何實際的文件夾名稱的護理,除非你打算使用它們作爲你的重置價值的作品。

+0

謝謝你的回覆!當我替換你的規則時,出現內部服務器錯誤;如果我註釋掉像#RewriteRule ^(。*)$ /microsites/index.php?uID=$1 [L]這樣的規則,那麼錯誤就會和我的規則一樣消失。 – jerrygarciuh 2010-01-12 18:50:23

+0

但是下面的作品並沒有拋出和錯誤?! RewriteRule ^([0-9])$ /microsites/index.php?uID=$1 [L] – jerrygarciuh 2010-01-12 18:54:46

0

檢查您的重寫日誌。我想你在重寫循環結束了,因爲^microsites/(.*)$由你重定向到(/microsites/index.php?uID=$1)的URL相匹配,以便它繼續循環,直到內部重定向你的最大數量滿足(默認爲10)

試試這個:

RewriteEngine on 
RewriteBase/
RewriteRule ^microsites/([^\.\?]+)$ /microsites/index.php?uID=$1 [L] 

這意味着(在僞代碼)

if we found a "microsites/" at the beginning 
and there are no "." or "?" characters, store this value in $1 
then redirect to /microsites/index.php?uID=$1 

所以第二次左右,它會看到你已經做了重定向,而不是永遠循環下去