Redirecting subdomains with mod_rewrite
August 19, 2005 4:01 PM
Subscribe
A subdomain redirection question (any mod_rewrite experts?)
So let's say that I'm setting up my new site, sports.com. Here is what I'd like to do:
When someone visits http://baseball.sports.com, I would like them to be redirected to http://sports.com/index.php?id=baseball (but transparently, so http://baseball.sports.com still appears in their browser). I would like to do this with several subdomains, but I don't need to handle *.sports.com (my webhost doesn't support wildcarded DNS entries anyway).
I realize I could fake this with frames, but that seems kind of lame. After wading through tons of .htaccess & mod_rewrite info, I'm more confused than ever. Can anyone help me pull this off?
posted by subclub to computers & internet (12 comments total)
RewriteCond %{HTTP_HOST} ([^.]+)\.sports.com [NC]
RewriteRule /index.php?id=%1
should work.
posted by nicwolff at 4:37 PM on August 19, 2005