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-14-2012, 04:44 PM   PM User | #1
the moose
New Coder

 
Join Date: Jul 2008
Posts: 86
Thanks: 5
Thanked 1 Time in 1 Post
the moose is an unknown quantity at this point
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.
the moose is offline   Reply With Quote
Old 06-15-2012, 01:59 AM   PM User | #2
the moose
New Coder

 
Join Date: Jul 2008
Posts: 86
Thanks: 5
Thanked 1 Time in 1 Post
the moose is an unknown quantity at this point
Does anyone have any idea how this is to be done with htaccess?
the moose is offline   Reply With Quote
Old 07-13-2012, 09:04 AM   PM User | #3
timgolding
Senior Coder

 
timgolding's Avatar
 
Join Date: Aug 2006
Location: Southampton
Posts: 1,460
Thanks: 89
Thanked 110 Times in 109 Posts
timgolding is on a distinguished road
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.
timgolding is offline   Reply With Quote
Old 07-15-2012, 09:09 PM   PM User | #4
schleppel
Regular Coder

 
Join Date: Oct 2004
Posts: 330
Thanks: 0
Thanked 13 Times in 13 Posts
schleppel is an unknown quantity at this point
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>
schleppel 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 10:48 PM.


Advertisement
Log in to turn off these ads.