2014-02-26 22 views
1

我使用WAMP和我的網址是localhost/hotel/hotels.php?id=21 使用重寫規則如下,廣東話重定向我的網址與htaccess的

Options +FollowSymLinks 
RewriteEngine on 
RewriteRule hotels/id/(.*)/ hotels.php?id=$1 
RewriteRule hotels/id/(.*) hotels.php?id=$1 

但沒有任何反應..

我mod_rewrite的是,也改變了做httpd.conf文件。

請給我一個處理這個問題的建議?

+0

「hotels.php?id = 21」應該發生什麼?我的意思是,'酒店/ ID/21'應該會發生什麼,但它不會改變'hotels.php?id = 21'的東西! – evuez

+0

是的,我希望它改成hotels/id/21,但沒有任何變化。甚至在做完所有事情之後,url仍然是一樣 – user3355237

+0

那麼你必須去'localhost/hotel/hotels/id/21',重寫規則不是重定向! – evuez

回答

1

您的RewriteRule必須使用flags。你可以改變它的跟隨

RewriteEngine on 
RewriteRule ^hotels/id/([\d]+)/?$ hotels.php?id=$1 [NC,L] 

您可以從

本地主機/賓館/酒店/ ID/12

如果你的.htaccess文件位於本地主機打電話給你的網頁/ hotel

+0

如何將原始頁面重定向到重寫的頁面..? – user3355237

+0

如果http://localhost/hotel/hotels.php?id = 21有效,您可以使用http:// localhost/hotel/hotels/id/21。如果您的.htaccess文件位於酒店文件夾中。請檢查.htaccess與http://stackoverflow.com/questions/4321990/htaccess-not-working-on-wamp – Huseyin