Forum Moderators: phranque
I am having trouble getting a rule to work and was hoping someone could help. I have two domain names pointing to the same IP, domain1.com and domain2.com. I want all calls to domain2.com to go to a specific page within domain1. The rule needs to work for domain2.com and www.domain2.com. I've seen examples that come close in this forum nothing that has worked for me yet. Here is what I have:
RewriteEngine on
RewriteCond %{HTTP_HOST} domain2.com$ [NC]
RewriteCond %{HTTP_HOST} www.domain2.com$ [NC]
RewriteRule ^(.*)$ /domain2.html [R=301,L]
Thanks for your help.
Welcome to WebmasterWorld!
You did not state whether you have *any* working rewriterules, so this may not apply. However, the first directive below is required to enable mod_rewrite on some servers -- those where this directive is not already present in the server configuration.
Eliminating the redundant second RewriteCond (your first one, having an unachored pattern, makes your second one redundant), and cleaning up a few minor points yields:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} domain2\.com [NC]
RewriteRule .* http://www.domain1.com/domain2.html [R=301,L]
Jim