开发者

Problem with RewriteCond %{QUERY_STRING}, backreference not dispaying in final URL

开发者 https://www.devze.com 2022-12-27 20:08 出处:网络
I have the following in my .htaccess file: RewriteCond %{QUERY_STRING} ^route\\=pro开发者_Go百科duct\\/category\\&path\\=35\\&page\\=([0-9]+)$

I have the following in my .htaccess file:

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

It's not behaving as expected though, when I enter the URL:

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

It gets rewritten to:

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

Could someone tell me what I have done wrong please?

Thanks,

eb_dev


To reference submatches of a RewriteCond directive, you need to use %n instead of $n:

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

精彩评论

暂无评论...
验证码 换一张
取 消