I've been having an issue for a little while with redirecting only certain URIs to HTTPS and the rest to HTTP.
What I want is the follow:
- The site to use HTTP for all pages unless explicitly told to use HTTPS
- Redirect these special pages to use HTTPS
- When in HTTPS, and you choose a non SSL page, to be redirected to HTTP.
The Problem:
Currently with the rules that I have (Found below) I can redirect from HTTPS to HTTP for all URIs except those explicitly defined. When redirecting to HTTPS for those defined URIs from HTTP the site seems to get stuck in a redirect loop.
The rewrites I am using are as follow:
- Code: Select all
# Force HTTP for non special pages.
RewriteCond %{SERVER_PORT} !^80$
RewriteCond %{REQUEST_URI} !^/special1(.*)$ [OR]
RewriteCond %{REQUEST_URI} !^/special2(.*)$
RewriteRule ^(.*)$ http://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
# Force HTTPS for special pages
RewriteCond %{SERVER_PORT} ^80$
RewriteCond %{REQUEST_URI} ^/special1(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/special2(.*)$
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
Thanks in advance,
Ash