Skip to content

Instantly share code, notes, and snippets.

@drench
Created November 11, 2010 02:06
Show Gist options
  • Save drench/671867 to your computer and use it in GitHub Desktop.
Save drench/671867 to your computer and use it in GitHub Desktop.
Wordpress: https for login, admin, shopping; http for everything else
# Did the user hit a page that should be https that should be http?
# Yes: redirect to https:
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(wp-admin|wp-login|wp-register|products-page)/.*$ https://wordpress.example.com/$1 [R=301,L]
# Did the user hit a page that should not be https, under https?
# Yes: redirect to http:
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/products-page/.*
RewriteCond %{REQUEST_URI} !^/wp-(admin|login|register).*
RewriteRule ^(.*/)$ http://wordpress.example.com/$1 [R=301,L]
# did the user hit the root with https?
# Yes: redirect to http:
RewriteCond %{HTTPS} on
RewriteRule ^$ http://wordpress.example.com/ [R=301,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment