Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-12-2011, 06:10 PM   PM User | #1
jasonpc1
Regular Coder

 
Join Date: Apr 2010
Posts: 417
Thanks: 4
Thanked 1 Time in 1 Post
jasonpc1 is on a distinguished road
rewrite url for multiple domains

Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^siteA.co.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www.siteA.co.uk$ [OR]

RewriteCond %{HTTP_HOST} ^siteA.com$ [OR]

RewriteCond %{HTTP_HOST} ^www.siteB.com$ [OR]
RewriteCond %{HTTP_HOST} ^siteB.com$

RewriteRule ^(.*)$ "http\:\/\/www.siteA\.com$1" [R=301,L]
what i am having problems with is getting the url to rewrite is that were to visit say

www.siteA.co.uk
www.siteA.co.uk
siteA.com
www.siteB.com
siteB.com

and be taken to

www.siteA.com

or say
www.siteA.co.uk/myOtherPage.php
www.siteB.com/myOtherPage.php

and be taken to

www.siteA.com/myOtherPage.php

Last edited by jasonpc1; 06-12-2011 at 06:14 PM..
jasonpc1 is offline   Reply With Quote
Old 07-09-2011, 08:28 AM   PM User | #2
Cags
New Coder

 
Join Date: Jul 2011
Posts: 67
Thanks: 0
Thanked 13 Times in 13 Posts
Cags is an unknown quantity at this point
What you have looks fairly accurate, but if you always want the same domain you could probably consider something along the lines of...

Code:
RewriteCond %{HTTP_HOST} !^www\.siteA\.co\.uk
RewriteRule .* http://www.siteA.co.uk%{REQUEST_URI} [R=301,L]
Cags is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:19 PM.


Advertisement
Log in to turn off these ads.