I know there are many similar threads, but none of them seems to match my exact problem. Here is what I’m trying to do:
(1) http://www.mydomain.com/ -> ht
Put this code in your DOCUMENT_ROOT/.htaccess file:
DOCUMENT_ROOT/.htaccess
RewriteEngine On RewriteCond %{HTTPS} off RewriteCond %{ENV:HTTPS} off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE] RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301,NE]