Created
June 12, 2018 14:45
-
-
Save voneff/bed412ac2a9fc8b7dbfb7362158c32dd to your computer and use it in GitHub Desktop.
WordPress: Redirect all to HTTPS, set HSTS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BEGIN Redirect to HTTPS and set HSTS | |
# | |
# Sources: | |
# https://stackoverflow.com/questions/40154500/hsts-301s-http-www-to-https-canonical-htaccess | |
# | |
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 | |
</IfModule> | |
# 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