How do I exclude a single directory from HTTPS to HTTP 301 redirect with IIS6+IIRF

260 views Asked by At

I already have a 301 from HTTPS to HTTP sitewide. But I want to exclude checkout pages so that they are always HTTPS (located in "/shopping-cart/")

Tried this:

#RewriteCond %{SERVER_PORT} ^443$
#RewriteRule ^(.*)$ http://www.example.com$1 [R=301]

#RewriteCond %{SERVER_PORT} ^80$
#RewriteCond %{HTTP_HOST} ^www.example.com$
#RedirectRule ^/shopping-cart(.*)$ https://%{HTTP_HOST}/shopping-cart$1 [R=301]

This gives me a redirect loop when I get to /shopping-cart/ pages

1

There are 1 answers

0
S.Krishna On

What I think is causing the loop is the sequence of the rules. Swap them and add the [l] tag to the shopping_cart rule (the [l] means "last" i.e. stop processing further rules if this rule matches)

#RewriteCond %{SERVER_PORT} ^80$
#RewriteCond %{HTTP_HOST} ^www.example.com$
#RedirectRule ^/shopping-cart(.*)$ https://%{HTTP_HOST}/shopping-cart$1 [R=301, l]

#RewriteCond %{SERVER_PORT} ^443$
#RewriteRule ^(.*)$ http://www.example.com$1 [R=301]