Answer the question
In order to leave comments, you need to log in
How to set up a redirect in nginx?
There are addresses localhost/catalog/test/element1/ localhost/catalog/test/element2/ for example, you need to redirect to new addresses localhost/catalog/test2/element1/ localhost/catalog/test2/element2/ taking into account all child elements
rewrite ^/catalog/test(.*) /catalog/test2$1 permanent;
Answer the question
In order to leave comments, you need to log in
The looping happens because the pattern test(.*)
matches test2.
Need to fix totest/(.*)
rewrite ^/catalog/test/(.*) /catalog/test2/$1 permanent;
RewriteCond %{REQUEST_URI} !^(.*)/catalog/test2$
RewriteRule ^/catalog/test(.*) /catalog/test2$1 [R=301,L]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question