Multiple domain rewrite

Using a single web hosting account to host multiple sites

Multiple domain rewrite

Postby Dr Madvibe » Mon Feb 19, 2007 5:34 am

First of all, my apologies for the probably basic questions. I have searched and tried to implement what I've found but ...

So, I have one main domain but thanks to a merger, several domains which now need to point to the main domain.

Main site:
www.mainsite.com

Other domains:
www.site2.com
www.site3.co.uk
www.site-4uk.com

At the moment, each domain returns the appropriate page from the mainsite appended to the domain name requested e.g.

www.mainsite.com/page1.shtml
www.site2.com/page1.shtml

are the same execpet for the domain name.

I would like all the "other domains" to "rewrite" to www.mainsite.com/page1.shtml

I read that a:

if domain is not mainsite
rewrite to mainsite

would do the trick but it's too hard for us thickies ;-) (at the moment)
Dr Madvibe
 
Posts: 2
Joined: Mon Feb 19, 2007 5:21 am

Postby richardk » Mon Feb 19, 2007 6:53 am

So you want to redirect so it always shows mainsite.com in the address bar of your browser?

In a .htaccess file in your document root:
Code: Select all
Options +FollowSymLinks

RewriteEngine On

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

Postby Dr Madvibe » Mon Feb 19, 2007 7:51 am

Thanks richardk

Yes, that's right, www.mainsite.com should be in the address bar. Dilutes the branding otherwise.

Some domain now work, others don't :(

I think there may be some other influences at work here though. DNS stuff
Dr Madvibe
 
Posts: 2
Joined: Mon Feb 19, 2007 5:21 am

Postby richardk » Mon Feb 19, 2007 8:55 am

As long as all the domains go to the same document root then they should all be redirected.

DNS shouldn't be the problem. Check the httpd.conf file for relevant AllowOverride lines that are not set to All.
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 70 guests

cron