.htaccess to require WWW for domain, but allow subdomain if existing with no hard coding
snippet in htaccess

.htaccess to require WWW for domain, but allow subdomain if existing with no hard coding

user4566

RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]