RewriteEngine On RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^(?:www.)?(.*)$ [NC] RewriteRule (.*) https://%1%{REQUEST_URI} [L,R=301]