Skip to content

Instantly share code, notes, and snippets.

@willmcclellan
Created September 18, 2012 17:46
Show Gist options
  • Save willmcclellan/3744583 to your computer and use it in GitHub Desktop.
Save willmcclellan/3744583 to your computer and use it in GitHub Desktop.
https to http and vice versa .htaccess
# Enable Rewrite Engine
RewriteEngine On
RewriteBase /
# http: rewrite rule to secure sections (redirect to https)
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^(/directoryA(.*)$|/directoryB(.*)$)$
RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
# http: rewrite rule for other pages (redirect to http)
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/directoryA(.*)$
RewriteCond %{REQUEST_URI} !^/directoryB(.*)$
RewriteRule (.*) http://%{SERVER_NAME}%{REQUEST_URI} [L,R]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment