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 4 of 4
  1. #1
    New Coder
    Join Date
    Jul 2008
    Posts
    86
    Thanks
    5
    Thanked 1 Time in 1 Post

    htaccess no-www for multiple domains

    So, I have 2 domains - one is an alias of the other.

    They are:

    www.mydomain.com
    www.mydomain.co.uk

    I want to use htaccess to ensure that the following combinations:

    mydomain.com/[whatever]
    mydomain.co.uk/[whatever]
    www.mydomain.com/[whatever]
    www.mydomain.co.uk/[whatever]

    all go to:

    www.mydomain.co.uk/[whatever]

    Just trying to have the domains active and not get the duplicate content for Google.

  • #2
    New Coder
    Join Date
    Jul 2008
    Posts
    86
    Thanks
    5
    Thanked 1 Time in 1 Post
    Does anyone have any idea how this is to be done with htaccess?

  • #3
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    i can tell you how its done with apache config if you can edit your apache configuration?

    See http://www.codingforums.com/showthread.php?t=267701
    You can not say you know how to do something, until you can teach it to someone else.

  • #4
    Regular Coder
    Join Date
    Oct 2004
    Posts
    375
    Thanks
    0
    Thanked 22 Times in 22 Posts
    With mod_rewrite
    Code:
    Options +FollowSymLinks
    
    RewriteEngine On
    
    # If it's not www.example.co.uk
    RewriteCond %{HTTP_HOST} !^www\.example\.co\.uk$ [NC]
    # Redirect to www.example.co.uk
    RewriteRule .* http://www.example.co.uk/$0 [R=301,L]
    With <VirtualHost>s
    Code:
    # Catch the "other" domains
    <VirtualHost *:80>
        ServerName example.co.uk
        ServerAlias example.com www.example.com
    
        # Redirect permanently to www.example.co.uk
        Redirect 301 / http://www.example.co.uk/
    </VirtualHost>
    
    # For www.example.co.uk
    <VirtualHost *:80>
        ServerName www.example.co.uk
    
        # other config...
    </VirtualHost>


  •  

    Posting Permissions

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