Skip to content

Instantly share code, notes, and snippets.

@yipo
Last active December 17, 2015 00:19
Show Gist options
  • Save yipo/5519916 to your computer and use it in GitHub Desktop.
Save yipo/5519916 to your computer and use it in GitHub Desktop.
Redirect from HTTP to HTTPS.
# 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>
@yipo
Copy link
Author

yipo commented May 5, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment