Jump to content


Photo

Redirect tld domain for .co


  • Please log in to reply
3 replies to this topic

#1 richrock

richrock

    Advanced Member

  • Members
  • PipPipPip
  • 213 posts
  • LocationWales, UK

Posted 28 January 2013 - 04:19 AM

Right, I'm fairly comfortable with redirecting other tld's, typically we'll redirect a .com to .co.uk - easy stuff.

But I'm stuck with someone who bought these : .co, .com and .co.uk

They want the .co.uk to be primary.

I've sorted the .com like this:

RewriteCond %{HTTP_HOST} ^(www\.)?thedomain\.com
RewriteRule (.*) http://www.thedomain.co.uk/$1 [R=301,L]

Which works fine. However, when I do


RewriteCond %{HTTP_HOST} ^(www\.)?thedomain\.co
RewriteRule (.*) http://www.thedomain.co.uk/$1 [R=301,L]

I get an infinite loop error, obviously caused by the .co.uk being included in the RewriteCond rule and then redirecting again....

Any ideas how I can resolve this?
If at first you don't succeed, you fail.

#2 Christian F.

Christian F.

    Advanced Member

  • Staff Alumni
  • 3,106 posts
  • LocationNorway

Posted 28 January 2013 - 08:12 AM

Try to add the following at the end of the first line:
(/|$)

That should match the domain only if it is followed by a slash, or the end of the line.
Keeping it simple.

#3 richrock

richrock

    Advanced Member

  • Members
  • PipPipPip
  • 213 posts
  • LocationWales, UK

Posted 31 January 2013 - 06:07 AM

You are a genius - I'll have to make a note of this. We had a run of clients who bought .co domains and now regret it for some reason.... Thanks
If at first you don't succeed, you fail.

#4 Christian F.

Christian F.

    Advanced Member

  • Staff Alumni
  • 3,106 posts
  • LocationNorway

Posted 31 January 2013 - 07:28 AM

You're welcome, glad I could help. :)
Keeping it simple.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com