RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*) http://www.%{HTTP_HOST}$1 [L,R=301] Code (markup): Is it possible to do the inverse of this i.e. if the www is present, to remove it but I don't want a static rule. I want it dynamic so it can be applied to all domains, i.e. in a dynamic virtual host.