Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

htaccess and Rewriting host name

Status
Not open for further replies.

Glowball

Programmer
Joined
Oct 6, 2001
Messages
373
Location
US
I know there are a lot of these issues in the forum but a search didn't turn up anything that fixed my problem. I have a subdomain that has its own domain name, and I want to make sure any requests for the subdomain are redirected to the domain name.

For example, anyone going to sub.domain1.com/page.htm or www.sub.domain1.com/page.htm needs to be redirected to www.domain2.com/page.htm. It needs to work for all requested pages under the subdomain.

This is what I have and it just doesn't work:

Code:
RewriteCond   %{REMOTE_HOST} ^(.*)sub\.domain1\.com [NC]
RewriteRule   ^(.+) %{HTTP_HOST} [C]
RewriteRule   ^(.*)sub\.domain1\.com(.*) [URL unfurl="true"]http://www.domain2.com/$2[/URL] [R,L]

I'm not a pro at htaccess rewrite rules -- can anyone help?

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top