D
D
Dmitry25902019-08-28 16:15:42
htaccess
Dmitry2590, 2019-08-28 16:15:42

How to make a 301 redirect in htaccess from one section from an https site to another section of another https site?

Good afternoon! Please tell me how to make a redirect in htaccess from one section from an https site to another section of another https site?
Those. so that when you go to the page https://domain1.ru/test1/fruits/ there is a redirect to https://domain2.ru/test2/fruits-test/
And when you go from https://domain1.ru/test1-test/ there was a redirect to https://domain2.ru/test2-test/

<ifModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ /converter/converter.php?request=$1 [L,QSA]
</ifModule>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Adamos, 2019-08-28
@Adamos

Redirect permanent /test1/fruits/ https://domain2.ru/test2/fruits-test/
Redirect permanent /test1-test/ https://domain2.ru/test2-test/

D
dodo512, 2019-08-28
@dodo512

Right after RewriteEngine on add

RewriteRule ^test1/fruits/$ https://domain2.ru/test2/fruits-test/ [R=301,L]
RewriteRule ^test1-test/$   https://domain2.ru/test2-test/        [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question