0

I originally bought the domain http://example.com with a hosting package and have run a Wordpress blog on that for a while.

Now I've bought an added on domain http://example.com.au and have duplicated the content but now want to write a 301 redirect.

As the new domain is an addon to the original server, it shares the .htaccess file and the general 301 redirect I've implemented has resulted in an infinite redirect loop.

What is the correct way to do this?

I attempted to follow instructions on an earlier thread posted here.

Essentially inserted this:

Options +FollowSymLinks
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^www.example.com [NC] 
RewriteRule (.*) http://www.example.com.au/$1 [R=301,L]
0
2

Here is the problem:

RewriteCond %{HTTP_HOST} ^www.example.com [NC]

This regex isn't terminated, so it matches both www.example.com and www.example.com.au.

To fix the problem, terminate the regex.

RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
3
  • Just tested on several links and that worked perfectly! Thank you so much, I'm very appreciative - I wish I could send you a beer! – user221193 May 25 '14 at 13:48
  • Just up vote then :) – Zapto May 25 '14 at 14:08
  • @t1nt1n Voting up requires 15 reputation. – Michael Hampton May 25 '14 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.