Last active
August 31, 2017 12:04
-
-
Save cuschk/d8535e149a731645a4d5 to your computer and use it in GitHub Desktop.
Redirect HTTP requests to non-www HTTPS
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 | |
RewriteBase / | |
# don't rewrite robots.txt | |
RewriteRule ^robots.txt$ - [L] | |
# redirect to non-www | |
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] | |
RewriteRule ^(.*)$ https://%1/$1 [R=301,L] | |
# redirect non-HTTPS to HTTPS | |
RewriteCond %{HTTPS} Off [or] | |
RewriteCond %{HTTPS} off | |
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment