Last active
September 13, 2019 13:13
-
-
Save Zillionx/1b001f94acfa4176550f74103049e66f to your computer and use it in GitHub Desktop.
.htaccess - HTTPS and www rewrite
This file contains hidden or 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
RewriteEngine On | |
## https and www rewrite | |
# https to www. | |
RewriteCond %{HTTP_HOST} !^www\. [NC] | |
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
# https (no Cloudflare proxied) | |
RewriteCond %{HTTP:X-Forwarded-Proto} !https | |
RewriteCond %{HTTPS} off | |
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
# https without www. | |
RewriteCond %{HTTP_HOST} ^www\. [NC] | |
RewriteRule ^ https://domain.tld%{REQUEST_URI} [R=301,L,NE] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment