Options -Indexes DirectoryIndex index.php RewriteEngine On RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} !^(localhost|127\.0\.0\.1)(:\d+)?$ RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] Header always set Strict-Transport-Security "max-age=31536000" "expr=%{HTTPS} == 'on'"