I was using this code to remove www from my domain:
# remove www
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
My problem is that I usually use subdomains and it doesn't work for them. (www.sub.example.com).
How do I rewrite to remove www whatever the domain is and even if it has subdomains?