If you want to force your website to use HTTPS and your main URL starts with “www”, you can use the code below.

RewriteEngine On

RewriteCond %{HTTPS} off

RewriteRule ^ https://www.domainname.com%{REQUEST_URI} [L,NE,R=301]