Last active
December 17, 2015 00:19
-
-
Save yipo/5519916 to your computer and use it in GitHub Desktop.
Redirect from HTTP to HTTPS.
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
# Reference: Apache Module mod_ssl | |
# http://httpd.apache.org/docs/current/mod/mod_ssl.html | |
<IfModule ssl_module> | |
# Reference: Apache Module mod_rewrite | |
# http://httpd.apache.org/docs/current/mod/mod_rewrite.html | |
<IfModule rewrite_module> | |
RewriteEngine on | |
RewriteCond %{HTTPS} off | |
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L] | |
</IfModule> | |
<IfModule !rewrite_module> | |
ErrorDocument 403 "Access here via the HTTPS protocal." | |
SSLRequireSSL | |
</IfModule> | |
</IfModule> | |
<IfModule !ssl_module> | |
ErrorDocument 403 "The module ssl_module is required." | |
Deny from all | |
</IfModule> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
HTTP_HOST vs. SERVER_NAME