I've had this working fine in my htaccess:
RewriteCond %{REQUEST_URI} ^/p/(.*)[NC]
RewriteRule (.*) /php/pages.php?type=product&code=%1 [QSA,L]
We recently set it up so all customers who log in will do so securely, so after logging in they're looking at an https page. I don't want my product pages to be secure, so I tried adding a rewrite like so:
RewriteCond %{server_port} =443
RewriteCond %{REQUEST_URI} ^/p/(.*) [NC]
RewriteRule (.*) http://example.com/p/%1 [R=301]
RewriteCond %{REQUEST_URI} ^/p/(.*)[NC]
RewriteRule (.*) /php/pages.php?type=product&code=%1 [QSA,L]
This looks to me like it should work, but it doesn't - the user is not redirected to a non-secure page, instead they remain on the https page (which loads fine). The strange thing is, if I add an L to the secure rewrite, both rewrites work correctly. How can that possibly be if they're both trying to be the last rewrite? Shouldn't one of them screw up the other?
RewriteCond %{server_port} =443
RewriteCond %{REQUEST_URI} ^/p/(.*) [NC]
RewriteRule (.*) http://example.com/p/%1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/p/(.*)[NC]
RewriteRule (.*) /php/pages.php?type=product&code=%1 [QSA,L]
Even though this works I don't want to go live with it since I don't understand it. We're on Apache version 2.2.18.
Anyone know what's going on, and/or how I can improve it?