Last active
November 8, 2017 13:54
-
-
Save cuschk/678dc57b19e230dae69f to your computer and use it in GitHub Desktop.
Redirect HTTP requests to a certain domain using 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 all requests to example.com with HTTPS | |
RewriteCond %{HTTP_HOST} !^example\.com$ [NC] | |
RewriteRule ^(.*)$ https://example.com/$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