2011-11-01 29 views
0

我是新來重寫URL,想知道我怎麼會改寫mod_rewrite的用戶ID錯誤

從這個 /資料/ 4

對此 /profile.php?id=4

我有這樣的規則至今

RewriteRule ^profile/([0-9]+)/?$ profile.php?id=$1 

,但它顯示這個瀏覽器

Firefox檢測到服務器正在以永不完整的方式重定向該地址的請求。

它在瀏覽器地址欄中顯示/profile/4/index.php錯誤。

.htaccess文件

<Files .htaccess> 
order allow,deny 
deny from all 
</Files> 

Options +FollowSymlinks 
RewriteEngine on 
#ErrorDocument 404 /test.php 
DirectoryIndex test.php 
RewriteRule settings editProfile.php 
RewriteRule update update.php 
RewriteRule home test.php 
RewriteRule ^profile/([0-9]+)/?$ profile.php?id=$1 
+1

你可以發佈你的整個.htaccess文件嗎? –

+0

爲什麼你需要整個.htaccess文件? mod_rewrite已啓用,我可以編寫其他網址而不是上面的網址。 – unleashed

+2

@unleashed由於Apache將使用您的整個'.htaccess'文件。 –

回答

4

你幾乎沒有。嘗試使用這個代替

RewriteRule ^profile/(.*)$ profile.php?id=$1 

我發現這個不錯的免費網上資源,以幫助您test your rewrite rules您發佈到您的網站直播之前。這可能有助於未來。看起來你的規則應該像你發佈的那樣工作。問題一定在其他地方。

+1

+1鏈接 – Peter

1

你的規則很好,所以有一個重定向的地方與它衝突。我想你沒有一個真實的目錄/profile/4,所以他們主要的候選人是mod_negotiation。試試這個:

Options -MultiViews 
+0

這有助於問題的感謝,雖然現在所有的CSS樣式和圖像都消失了。我認爲這可能會影響他們在重寫過程中。 – unleashed

+2

這是一個完全不同的問題。您可能正在使用相對路徑,而您剛剛更改了文檔的網址。 –

+0

不用擔心,解決了這個問題:) – unleashed