Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteCond %{SERVER_PORT} =80
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
или
RewriteCond %{HTTP_HOST} !^(www\.)
localhost.com$
RewriteCond %{HTTP_HOST} ^(.*?)\.
localhost.com$
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*?)$ https://%{HTTP_HOST} [nc]
не работают