R
R
rbah19872021-10-20 21:06:43
htaccess
rbah1987, 2021-10-20 21:06:43

How to make a redirect from the old directory and its subdirectories to the new one in .htaccess?

How to make a redirect for
site.ru/cat
and
site.ru/cat/...
to
site.ru/new_cat

That is, if you go to site.ru/cat/23 or site.ru/cat, it still only redirects to site. en/new_cat

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2021-10-20
@rbah1987

RewriteCond %{REQUEST_URI} ^/cat/(.*)$ 
   # если строка начинается с /cat/ 
RewriteRule ^(.*)$ /new_cat/%1 [R=301,L] 
   #Перенаправить все URL с начинающиеся с dir1 на dir2 с сохранением дальнейшей структуры URL

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question