Wildcard subdomain mapping with mod_rewrite

This is my .htaccess file:

Code:
RewriteEngine on 
rewriteCond %{HTTP_HOST} !^www.example.com [NC] 
rewriteCond %{HTTP_HOST} ^(.*)\.example\.com [NC] 
rewriteRule .* http://www.example.com/index.php?%1 [L]
When I use [R,L] instead of [L], sub.example.com works, and redirects to example.com/index.php?sub

However, I do not want a redirect (I want the user to see sub.example.com in their address bar) so I use just [L]. The rewrite no longer works and I get stuck in some kind of infinite loop. (apache error_log : maximum number of internal redirects reached)

here's a link to my rewritelog: http://rafb.net/paste/results/10f42H40.html

Any ideas why this is happening? I got the .htaccess code from this very forum, so it seems odd that it isn't working for me.

Thanks!

 

 

 

 

Top