A
A
Al fox2020-05-03 18:59:16
htaccess
Al fox, 2020-05-03 18:59:16

How to 301 redirect an old domain with subdomains to a new domain with subdomains?

There is a domain https://domain1.ru with subdomains of the form https://omsk.domain1.ru and https://tomsk.domain1.ru
You need to redirect to a new domain and the corresponding subdomains of the new domain2.ru

Example:
https:/ /domain1.ru -> https://domain2.ru
https://omsk.domain1.ru -> https://omsk.domain2.ru
https://tomsk.domain1.ru -> https://tomsk. domain2.ru

Found as soon as the main domain is redirected, but how to redirect all 3rd-level domains with one entry?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
wisgest, 2020-05-03
@AleBas

For a domain with subdomains of all levels:

RewriteCond %{HTTP_HOST} ^((?:[^.]+\.)*)domain1\.ru$ [NC]
RewriteRule "" https://%1domain2.ru%{REQUEST_URI} [R=301]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question