Page 1 of 1

Mod rewrite sub domains

Posted: Thu Sep 21, 2006 12:49 pm
by GeXus
I setup wildcard DNS.. so that anything.domain.com will basically be domain.com

What I want to do is setup mod rewrite so (.*).domain.com will be domain.com/?id=$1

Anyone know how I would set the rewrite rule for the sub domain?

Thanks!

Posted: Thu Sep 21, 2006 2:18 pm
by GeXus
Got it figured out... here is the code for anyone interested

Code: Select all

RewriteEngine on
ReWriteCond %{HTTP_HOST} !^$
ReWriteCond %{HTTP_HOST} !www\.domain\.com
ReWriteCond %{HTTP_HOST} (.*)\.domain\.com
ReWriteRule (.*) dir/index.php?id=%1 [QSA]