http://www.perlmonks.org?node_id=797692


in reply to Re: (OT) mod_rewrite anyone?
in thread (OT) mod_rewrite anyone?

...and the second entry Canonical Hostnames explains how you would achieve this.
Yes but I need a wildcard. I tried something like
RewriteCond %{HTTP_HOST} !^www\.%1 [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^/?(.*) http://www.%1/$1 [L,R,NE]
but not working. These rules are so hard :(