Mod rewrite sub domains

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Mod rewrite sub domains

Post 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!
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Post 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]
Post Reply