.htaccess - Redirect NON-www to www for https - Stack Overflow

RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) https://www.example.com%{REQUEST_URI} [L,R=301]...

Read more here: .htaccess - Redirect NON-www to www for https - Stack Overflow.