4

我的 .htaccess 文件中有以下内容:

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]

但是,当我输入 URL 时,它的行为并不像预期的那样:

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

它被重写为:

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

有人可以告诉我我做错了什么吗?

谢谢,

eb_dev

4

1 回答 1

9

要引用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]
于 2010-04-24T08:56:10.333 回答