Skip to content

Instantly share code, notes, and snippets.

@therealjustinlong
Last active August 29, 2015 14:03
Show Gist options
  • Save therealjustinlong/a4b1c90d204bbe36b7de to your computer and use it in GitHub Desktop.
Save therealjustinlong/a4b1c90d204bbe36b7de to your computer and use it in GitHub Desktop.
.htaccess for checking if HTTPS or HTTP
<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