How to redirect multiple domains to one domain?

I have about 4 domains that need to be redirected to a new one.

Team Leader Asked on December 11, 2018 in PHP.
Add Comment
1 Answer(s)

You can redirect multiple domains to one domain using .htaccess file

Here 4 domains are redirect1.com,redirect2.com,redirect3.com and redirect4.com.These domains are redirected to example.com

Code Example:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^example\.com$ [OR]

RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^/?$ "http\:\/\/example\.com\/" [R=301,L]

RewriteCond %{HTTP_HOST} ^redirect1\.com$ [OR]

RewriteCond %{HTTP_HOST} ^www\.redirect1\.com$
RewriteRule ^/?$ "http\:\/\/example\.com\/" [R=301,L]

RewriteCond %{HTTP_HOST} ^redirect2\.com$ [OR]

RewriteCond %{HTTP_HOST} ^www\.redirect2\.com$
RewriteRule ^/?$ "http\:\/\/example\.com\/" [R=301,L]

RewriteCond %{HTTP_HOST} ^redirect3\.com$ [OR]

RewriteCond %{HTTP_HOST} ^www\.redirect3\.com$
RewriteRule ^/?$ "http\:\/\/example\.com\/" [R=301,L]

RewriteCond %{HTTP_HOST} ^redirect4\.com$ [OR]

RewriteCond %{HTTP_HOST} ^www\.redirect4\.com$
RewriteRule ^/?$ "http\:\/\/example\.com\/" [R=301,L]
Team Leader Answered on December 13, 2018.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.