2010-04-24 52 views
4

我已經在我的.htaccess文件如下:問題用的RewriteCond%{QUERY_STRING},反向引用不dispaying最終URL

RewriteCond %{QUERY_STRING} ^route\=product\/category\&path\=35\&page\=([0-9]+)$ 
RewriteRule ^index\.php$ http://%{HTTP_HOST}/product/category/35/page_$1? [R=301,L] 

它不表現爲人們的預料之中,當我輸入的網址:

http://example.com/index.php?route=product/category&path=35&page=2 

它被改寫爲:

http://example.com/product/category/35/page_ 

有人能告訴我什麼,我做錯了嗎?

感謝,

eb_dev

回答

8

要引用RewriteCond指令的子匹配,你需要使用%n而不是$n

RewriteCond %{QUERY_STRING} ^route=product/category&path=35&page=([0-9]+)$ 
RewriteRule ^index\.php$ /product/category/35/page_%1? [R=301,L] 
+0

感謝濃湯!你的傳奇! – 2010-04-24 13:04:11