Redirecting all urls to the root of another domain

Using a single web hosting account to host multiple sites

Redirecting all urls to the root of another domain

Postby dan2313 » Wed Nov 21, 2007 4:00 am

Hi

Apologies if this has be answered before, I'm new Linux hosting :)

I'm trying to redirect any URL on a spare domain i have, to the root of my main domain. However it seems to retain the querystrings of the spare domain and append them to my main domain.

I'm currently using

RewriteCond %{HTTP_HOST} ^spare-domain.co.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www.spare-domain.co.uk$
RewriteRule ^(.*)$ http://www.maindomain.co.uk [R=301,L]

Any help would be much appreciated.

Thanks in advance.

Dan
dan2313
 
Posts: 2
Joined: Wed Nov 21, 2007 3:53 am

Postby richardk » Wed Nov 21, 2007 2:38 pm

When redirecting, adding a ? after the new URL removes the query string.

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?spare-domain\.co\.uk$ [NC]
RewriteRule .* http://www.maindomain.co.uk/? [R=301,L]
Last edited by richardk on Thu Nov 22, 2007 12:47 pm, edited 1 time in total.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby dan2313 » Thu Nov 22, 2007 6:19 am

Awesome that works great.

Thanks for your help

Dan
dan2313
 
Posts: 2
Joined: Wed Nov 21, 2007 3:53 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 26 guests

cron