Last active
August 29, 2015 14:03
-
-
Save therealjustinlong/a4b1c90d204bbe36b7de to your computer and use it in GitHub Desktop.
.htaccess for checking if HTTPS or HTTP
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
<IfModule mod_rewrite.c> | |
# Custom secure redirect variable: | |
# Test that HTTPS is on: | |
# RewriteCond %{ENV:SECURE_REDIRECT} on [NC] | |
# or | |
# Test that HTTPS is NOT on: | |
# @ RewriteCond %{ENV:SECURE_REDIRECT} !on [NC] | |
# Simple Example code: | |
RewriteEngine On | |
RewriteCond %{ENV:SECURE_REDIRECT} !on [NC] | |
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment