Well I have a site that uses relative paths for all the URLs. I just added a shopping cart so the two or three checkout pages are using HTTPS instead of HTTP. My problem is that a user is mid way through checkout and clicks a link on the navigation or whatever it seems them to that page with HTTPS when it is a page that doesn't require it (and it some cases can't handle it because of external files e.g. GoogleMaps.js)
+1
A:
you can try doing something like
RewriteCond %{SERVER_PORT} !^(80|8080)$
RewriteCond %{REQUEST_URI} !^(checkout|order|etc)$
RewriteRule ^(.*)$ http://yoururl$1
I'm not sure if it works because I didn't test it, but you could use the ideea of testing for {SERVER_PORT}. Hope it helps
andi
2009-03-17 18:34:01
You answered this while I was typing my answer. I like yours better though!
Andrew G. Johnson
2009-03-17 18:36:18
it's pretty much the same thing.actually, using %{HTTP_HOST}%{REQUEST_URI} like you did is more elegant :)
andi
2009-03-17 18:38:11
Better not to rely on port numbers. Check if HTTPS is on (or off, if you want to force it on).
Scott
2009-03-17 18:39:22
Yeah. Scott is probably right. I used port because I didn't know about %{HTTPS}.
andi
2009-03-17 18:44:14
Agreed, %{HTTPS} is the thing to use here.
David Zaslavsky
2009-03-17 19:08:29
+3
A:
Actually surprised myself and hacked something together. Reroutes everything that isn't www.domain.com/checkout
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^(/checkout)
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Andrew G. Johnson
2009-03-17 18:35:34
A:
You don’t need the additional RewriteCond
directive to exclude /checkout/…
:
RewriteCond %{HTTPS} on
RewriteRule !^checkout(/|$) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Gumbo
2009-03-17 18:46:28
A:
This is what I have in my .htaccess :
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
For some reason it is not working. Seems like it doesn't recognize https access through %{HTTPS} ?!
Amir E. Habib
2009-11-25 09:11:51