Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Apr 2010
    Posts
    417
    Thanks
    4
    Thanked 1 Time in 1 Post

    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 07:14 PM.

  • #2
    New Coder
    Join Date
    Jul 2011
    Posts
    67
    Thanks
    0
    Thanked 13 Times in 13 Posts
    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]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •