My apologies if I'm hijacking this thread, but I have a question along these lines...
I am trying to accomplish the following:
-Our company owns several domain names and I'd like whichever domain the user enters in to be redirected to a corresponding page on our "main" domain.
-If someone puts in
http://domain.com (with or without www), I'd like to redirect them to
http://www.maindomain.com/page.htm.
AND
-If someone puts in
http://domain.com/page.htm (with or without www), I'd like to redirect them to
http://www.maindomain.com/page.htm.
The page.htm file will be different depending on what domain the user entered in (domain1.com will go to maindomain.com/page1.htm, domain2.com will go to maindomain.com/page2.htm). Even if the user doesn't enter in the specific page name for the old domain, I would still like them to be directed to maindomain.com/page1.htm because the domain name itself is descriptive. Below is the code I have so far:
- Code: Select all
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com$ [NC]
RewriteRule ^$ http://www.maindomain.com/page2.html [R=301,QSA,L]
RewriteCond %{HTTP_HOST} ^(www\.)?domain3\.com$ [NC]
RewriteRule ^$ http://www.maindomain.com/page3.html [R=301,QSA,L]
Can I also add in the following code to make sure that IF the user enters in the page directly (instead of just the domain name), that they will be directed to the maindomain.com? ie. user types in "domain1.com/page1.htm" that they be directed to "maindomain.com/page1.htm"?
- Code: Select all
#redirect domain1/page1.htm to domain/page1.htm
RewriteCond %{HTTP_HOST} ^(www\.)?domain1\.com [NC]
RewriteRule ^(.*)\.htm$ http://www.domain.com/$1.htm [R=301,L]
Thanks!
Ryan