I have several parked domains that I want to redirect to a primary domain. So using:

RewriteCond %{HTTP_HOST} ^domain2\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain2\.com$
RewriteRule ^(.*)$ "http\:\/\/domain1\.com\/$1" [R=301,L]

and other various in the .htaccess file the result is that

  • domain2.com redirects to domain1.com
  • but domain2.com/somepage does not redirect to domain1.com/sompage
  • instead domain2.com/somepage is redirected to domain1.com/index.php

I really try not to create duplicate posts, so I've had a darn good look around, but I'm probably not using the right terms. So any help and / or links etc would be a great help.

Thanks.

Comments

p55mac’s picture

Ok after much more research and experimentation I found out that the rewrite rule is ok, it just needs to go above other rewrite codes in the .htaccess file.

I moved the code above the
# Various rewrite rules.
line in the .htaccess file and BOOM it worked.

Hope this helps someone.

carsonw’s picture

This helped me out p55mac. Thank you very much!

uNeedStuff’s picture

After many hours reading and searching and reading more, and even chatting with support on my host account. This worked :)
I can't say thank you enough!

I was actually working on a wordpress site.. and put it above the wordpress stuff and I did have to add
RewriteEngine On
RewriteBase /

I do also use Drupal :)