K
K
K S2021-06-24 13:17:00
htaccess
K S, 2021-06-24 13:17:00

How to redirect a section from one site to another?

I found a question on Habré , but htaccess stubbornly refuses to do a redirect.

The task is this, there is a site https://site.ru/test/test2

It is necessary to redirect /test/ to /test3/ to https://newsite.ru/test3 , but so that all /test/ subsections and product cards open along a new path, i.e. https://newsite.ru/test3/test2

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Taran, 2021-06-24
@kab7771s_sinelnikov

RewriteRule ^test/(.+)$ /test3/$1 [R=301,L]
Where .+any number of characters from 1 or more
A is ()a group (simple grouping)
and, accordingly, $1 this is the same 1 group that was created, so everything in it will be thrown

K
K S, 2021-06-24
@kab7771s_sinelnikov

It turned out for such an operator,
RewriteRule ^test/$ https://newsite.ru/test3 [R=301,L]
RewriteRule ^test/test2/$ https://newsite.ru/test3/test2 [R=301,L ]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question