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

My .htaccess file has the following:

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] 

This is not as expected when I enter the URL:

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

It corresponds to:

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

Can someone tell me what I did wrong, please?

Thanks,

eb_dev

+4
source share
1 answer

To reference the submatrices of the 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] 
+8
source

Source: https://habr.com/ru/post/1307855/


All Articles