Forum Moderators: phranque

Message Too Old, No Replies

Direct multiple domains to single domain using htaccess file

redirect multiple domains to single domain

         

frantzs

4:18 pm on Feb 17, 2014 (gmt 0)

10+ Year Member



We're having an issue routing our website to it's new domain. We have a total of 3 domains.

domain1.com
domain2.com
domain3.com

Where domain3.com is the new domain that domain1.com and domain2.com need to directed to.

Our current .htaccess file is setup link so:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

RewriteCond %{HTTP_HOST} ^www\.domain1\.com [OR]
RewriteCond %{HTTP_HOST} ^domain1\.com [OR]
RewriteCond %{HTTP_HOST} ^www\.domain2\.com [OR]
RewriteCond %{HTTP_HOST} ^domain2\.com [OR]
RewriteCond %{HTTP_HOST} ^domain3\.com.com
RewriteRule ^(.*)$ http://www.domain3.com/$1 [R=permanent,L]

RewriteCond %{HTTP_HOST} !^www\.(.*)
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L]



What's working:

domain2.com successfully redirects to domain3.com

domain3.com successfully goes to domain3.com

What's not working:

domain1.com DOES NOT redirect to domain3.com


Question
What must be changed in the .htaccess file to get domain1.com to also redirect permanently to domain3.com?

Thank you in advance!

wilderness

6:51 pm on Feb 17, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Just do site search (near top of page) on "domain2", as this comes up frequently.

lucy24

4:19 am on Feb 18, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Not enough information. Do they all physically live in the same directory of the same server? And what's with that "index.php" line? That's much too early; it has to come after the domain-name redirects or you've suddenly got, er, sextuple content.

g1smd

7:01 am on Feb 18, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



In the root folder where each hostname resolves to:

# External canonical hostname redirect
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

# Internal rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /index.php?q=$1 [L,QSA]

where, in both cases,
www.example.com
is the hostname you are redirecting to.