How can I change my rewrite rule to keep the original subdomain url in the address bar?

Currently if I type in "username.domain.com" it gets redirected to "domain.com/username"...and I would like the address bar to stay at "username.domain.com".

I'm using wildcard subdomains with this rewrite rule in my httpd.conf file:

<IfModule mod_rewrite.c>
   Options +FollowSymLinks
   Options +Indexes
   RewriteEngine On
   RewriteCond %{HTTP_HOST} !www.domain.com$ [NC]
   RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+).domain.com [NC]
   RewriteRule ^(.*)$ http://domain.com/sites/%2 [L]
</IfModule>

Is this even possible?

Thanks in advance.

link|improve this question

50% accept rate
feedback

1 Answer

If you change the last line to proxy rather than redirect, I think that will get you the behavior you want:

RewriteRule ^(.*)$ http://domain.com/sites/%2 [P,L]
link|improve this answer
+1 but note that you need mod_proxy enabled for this to work. Be extremely careful when enabling mod proxy! It's somewhat easy to create an open proxy, see the Mod_Proxy page, in particular the ProxyPass directive, for more information. – Chris S Feb 15 '11 at 20:49
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.