I\'ve got a VirtualHost that looks something like:
ServerName domain1.com
ServerAlias www.domain1.com domain2.com www.domain2.com
Your RewriteCond is a bit wonky. I'm surprised it does anything at all, since it would seem to be trying to match the host www.domain1.com
against the pattern www\.www.domain1.com
. These directives worked for me:
# Redirect www to non-www
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1$1 [L,R=301]