Community

.htaccess 301 redirect parked domain not working for domain.com/somepage

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

It's all about the order

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.

This helped me out p55mac.

This helped me out p55mac. Thank you very much!