Last active
August 11, 2016 16:57
-
-
Save jopfre/8c791000038d00faad2637e9ed8134a6 to your computer and use it in GitHub Desktop.
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
#http://stackoverflow.com/a/27029144 | |
RewriteEngine On | |
# match any URL with www and rewrite it to https without the www | |
RewriteCond %{HTTP_HOST} ^(www\.)(.*) [NC] | |
RewriteRule (.*) https://%2%{REQUEST_URI} [L,R=301] | |
# match urls that are non https (without the www) | |
RewriteCond %{HTTPS} off | |
RewriteCond %{HTTP_HOST} !^(www\.)(.*) [NC] | |
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment