Reputation: 413
I'm trying to achieve the following:
Redirect all WWW requests to equivalent (without WWW)
Redirect all HTTPS requests to HTTP
Redirect all requests to subdirectory /cart to force HTTPS
Here is what I have but it's giving me a loop.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(cart/.*)$ https://example.com/$1 [R,L]
RewriteRule ^(.*)$ http://example.com/$1 [R,L]
Upvotes: 1
Views: 89
Reputation: 41219
RewriteEngine On
#www to non-www
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule ^(.*)$ http://example.com/$1 [R,L]
#https to http
RewriteCond %{HTTPS} ^on$
RewriteRule ^(.*)$ http://example.com/$1 [R,L]
#if the request is for /cart then enable https
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} ^/cart
RewriteRule ^(.*)$ https://example.com/$1 [R,L]
Upvotes: 1