M
M
Merlin17282019-05-27 22:00:58
htaccess
Merlin1728, 2019-05-27 22:00:58

Redirection from domain to domain, plus a bunch of subdomains, how to implement on .htaccess?

Hello.
There is a project to a bunch of subdomains. I'm moving to another domain with all these subdomains.
domain1.com/primer to domain.com2/primer
ga.domain1.com/hdaj to ga.domain2.com/hdaj
jask.domain1.com/sajk/isuai to jask.domain2.com/sajk/isuai
and so on, subdomains several hundred, tens of thousands of pages
How to register all this in htaccess?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2019-05-28
@shambler81

Your question is written incorrectly, so there will be an incorrect answer.
at least there is no domain.com2 domain, and therefore you have already shown something wrong, so I will assume.
But based on my thoughts, I can assume that you needed this

RewriteCond %{HTTP_HOST} ^(.+)\.domain1\.com$ [NC] 
RewriteRule ^(.*)$ https://%1.domain2\.com/$1 [R=301,L]

will work for all 3rd level domains
(.+)- one or more characters
\.- just dot escaped.
%1- analogue of $1 but from RewriteCond

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question