6 domains, 1 document root, need all to point to one domain

Using a single web hosting account to host multiple sites

6 domains, 1 document root, need all to point to one domain

Postby charlier » Sun May 13, 2007 8:16 pm

Hey everyone,

I have been told by many, that mod_rewrite is my solution. Is there any "official" documentation on this?

Perhaps one could help me out real quick and show me the basics of what I'm trying to do.....

Scenario. I have 6 domains. They all point to the same server, and the same document root. I'd like them all to redirect to the root domain of www.domain1.com instead of www.domain2.com or www.domain3.com.

I have messed around with some examples and probably have confused myself over what at all I may have. I keep getting perpetual loops,.... never ending loops is probably a better word.

Can someone give me a quick example of how you'd accomplish this with say at least 2 domains? I think I can figure it out after that.

I'd imagine I need a rule to be something like, if address is anything but www.domain1.com, go to www.domain1.com.

Thanks for any possible help....

Charlie
charlier
 
Posts: 1
Joined: Sun May 13, 2007 8:10 pm

Postby richardk » Mon May 14, 2007 9:25 am

Apache mod_rewrite Documentation.

Try this
Code: Select all
Options +FollowSymLinks

RewriteEngine On

# If it's not the main domain.
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
# Redirect to the document root.
RewriteRule .* http://www.domain.com/? [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Follow Up

Postby weslinda » Tue Jun 19, 2007 6:24 am

I think this is the same thing that I need to do, but want to confirm. I have three domains that the previous web team setup, and directed them all to the same content. I want to eventually get to using one domain, and I think this is the way to do it.

Can anyone confirm this?

Any help is greatly appreciated.
weslinda
 
Posts: 1
Joined: Tue Jun 19, 2007 6:07 am

Postby richardk » Tue Jun 19, 2007 9:55 am

To preserve the URL after the domain, eg. domain1.com/abc to maindomain.com/abc, domain2.com/def to maindomain.com/def, you would need this in a .htaccess file in your document root
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 6 guests

cron