Code:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^(.*) https://domain.com%{REQUEST_URI} [R=301,L,NE]
RewriteBase /
or direct to www + https
Code:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*) https://www.domain.com%{REQUEST_URI} [R=301,L,NE]
RewriteBase /
In human words: if not https or if not starts with www direct to https + www retaining the params after the domain. Take notice of the placing; after RewriteEngine On, before RewriteBase