Welcome to WebmasterWorld Guest from 50.17.5.36

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Direct multiple domains to single domain using htaccess file

redirect multiple domains to single domain

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

New User

joined:Feb 17, 2014
posts: 1
votes: 0


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!
6:51 pm on Feb 17, 2014 (gmt 0)

Senior Member

WebmasterWorld Senior Member wilderness is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Nov 11, 2001
posts:5408
votes: 2


Just do site search (near top of page) on "domain2", as this comes up frequently.
4:19 am on Feb 18, 2014 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

joined:Apr 9, 2011
posts:12708
votes: 244


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.
7:01 am on Feb 18, 2014 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


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.