Force www and ignore all other subdomains in .htaccess

This version does not require you to hard-code the domain name, and takes into account SSL connections.

RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]