cancel
Showing results for 
Search instead for 
Did you mean: 

htaccess redirect for two sites

Vega
Rising Star
Posts: 118
Thanks: 14
Registered: ‎22-06-2009

htaccess redirect for two sites

Hi
I currently use this code in my .htaccess file to redirect one of my domains to a folder on my ccgi space as follows...

RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.]+\.)?yourdomain\.co\.uk$ [NC]
RewriteCond %{REQUEST_URI} !^/yoursite/
RewriteRule (.*) /yoursite/$1

However I now have a second domain (lets call it 'otherdomain.co.uk'). Does anyone have any idea how I can get this working while still keeping my other domain redirect intact?
Regards
Matt
6 REPLIES 6
bobpullen
Community Gaffer
Community Gaffer
Posts: 16,887
Thanks: 4,979
Fixes: 316
Registered: ‎04-04-2007

Re: htaccess redirect for two sites

Just add the three directives for your new domain to the same .htaccess file.

Bob Pullen
Plusnet Product Team
If I've been helpful then please give thanks ⤵

Vega
Rising Star
Posts: 118
Thanks: 14
Registered: ‎22-06-2009

Re: htaccess redirect for two sites

a htaccess query that simple?  surely not!  Grin

Thanks Bob
Vega
Rising Star
Posts: 118
Thanks: 14
Registered: ‎22-06-2009

Re: htaccess redirect for two sites

Hi Bob
I've updated the .htaccess file as follows
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.]+\.)?yourdomain\.co\.uk$ [NC]
RewriteCond %{REQUEST_URI} !^/yoursite/
RewriteRule (.*) /yoursite/$1
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.]+\.)?otherdomain\.co\.uk$ [NC]
RewriteCond %{REQUEST_URI} !^/otherdomain/
RewriteRule (.*) /otherdomain/$1

However when visiting http://otherdomain.co.uk ; is goes to my standard PN webspace
If I go to www.otherdomain.co.uk it gives me a HTTP 403 error
My domain settings in the portal are as follows
Left Field                        Type                  Pri            Right Field
otherdomain.co.uk.        A                                        91.136.8.9
www                              CNAME                              otherdomain.co.uk.
Is this correct? If so, will it work right away after updating the DNS records?
Cheers
bobpullen
Community Gaffer
Community Gaffer
Posts: 16,887
Thanks: 4,979
Fixes: 316
Registered: ‎04-04-2007

Re: htaccess redirect for two sites

Can you see the new domain listed in the management drop-down at the top of the hosting control panel? If not, then you'll need to raise a ticket requesting that it's added to your hosting account. We might also need to change the 'web service' of your domain to avoid clashes with some of the default DNS records.

Bob Pullen
Plusnet Product Team
If I've been helpful then please give thanks ⤵

Vega
Rising Star
Posts: 118
Thanks: 14
Registered: ‎22-06-2009

Re: htaccess redirect for two sites

Hi Bob
I'm not sure if this is the same area as you mentioned but it is listed under My Account > Domain Names. See attached screen shot of the domain and its settings I have done by selecting the 'Other' option under Domain Hosting Settings. (I've based them on my other domain which points to a ccgi folder and presumed the same logic would work).
Regards
bobpullen
Community Gaffer
Community Gaffer
Posts: 16,887
Thanks: 4,979
Fixes: 316
Registered: ‎04-04-2007

Re: htaccess redirect for two sites

The new domain wasn't present on your hosting account. I've added it and you should find that www traffic is now pointing correctly. Keep an eye on the http://otherdomain.co.uk  address and let me know if it's still not pointing to the correct webspace tomorrow.

Bob Pullen
Plusnet Product Team
If I've been helpful then please give thanks ⤵