views:

218

answers:

1

I am trying to mod-rewrite based on a sub-domain. How do I take the subdomain and append it to the end of my new domain?

Example:

RewriteCond %{HTTP_HOST} ^users\.example\.com$
RewriteRule ^(.*)$    http://www.example.com/?subdomain=[variable for sub]     [L]

How do I get 'users' into [variable for sub]?

+2  A: 

Matches from the last RewriteCond are stored as %N so you can do this:

RewriteCond %{HTTP_HOST} ^(users)\.example\.com$
RewriteRule ^(.*)$    http://www.example.com/?subdomain=%1 [L]
Greg