homepage Welcome to WebmasterWorld Guest from 54.227.41.242
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Direct multiple domains to single domain using htaccess file
redirect multiple domains to single domain
frantzs




msg:4646097
 4:18 pm on Feb 17, 2014 (gmt 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!

 

wilderness




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

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

lucy24




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

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




msg:4646244
 7:01 am on Feb 18, 2014 (gmt 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.
Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved