Last active
May 17, 2018 14:55
-
-
Save wesort/28dc0fc3d688f8ff88d5af4a385b0384 to your computer and use it in GitHub Desktop.
HTTPS: htaccess redirect from http, http + www, and https + www
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
RewriteEngine On | |
# | |
# Redirect all http and www traffic to https non-www URL | |
# Ref for all but first line: https://simonecarletti.com/blog/2016/08/redirect-domain-http-https-www-apache/ | |
# Ref to correct for Webfaction using nginx ssl proxy: cpbotha.net... https://goo.gl/Vnbdw9 | |
# | |
RewriteCond %{HTTP:X-Forwarded-SSL} !on [OR] | |
RewriteCond %{HTTP_HOST} ^www\. [NC] | |
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC] | |
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment