Answer the question
In order to leave comments, you need to log in
301 redict from any nesting, how?
Good afternoon.
Please tell me how to implement a 301 redict from any nesting to without it. For example:
1. site/elektroinstrument/kategorii/perforatory/perforator-m12-ch-202c/ to site/perforator-m12-ch-202c/
2. site/rezak-dlya-plastikovyh-trub/ to site/rezak-dlya- plastikovyh-trub/ (i.e. if there is no nesting, then leave)
3. website/rezaki/rezak-dlya-plastikovyh-trub.html to website/rezak-dlya-plastikovyh-trub
/ remove any nesting and if it ends with .html, then change to /
Answer the question
In order to leave comments, you need to log in
# если минимум 1 символ до последнего конца строки, и убираем слеш еслион есть.
RewriteCond %{REQUEST_URI} .*(/.+)(|/)$
# то пенренаправить все на сайт и то что в скобках.
RewriteRule ^(.*)$ http://site.ru%1 [R=301,L]
RewriteCond %{REQUEST_URI} ^(.+)\.html$
RewriteRule ^(.*)$ %1/ [R=301,L]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question