Skip to content

Instantly share code, notes, and snippets.

Created Jun 12, 2018
What would you like to do?
WordPress: Redirect all to HTTPS, set HSTS
# BEGIN Redirect to HTTPS and set HSTS
# Sources:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [NE,L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
<IfModule mod_headers.c>
Header set Strict-Transport-Security "max-age=31536000" env=HTTPS
# END Redirect to HTTPS and set HSTS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment