dsol828
dsol828

Reputation: 413

htaccess Redirect https for specific directory

I'm trying to achieve the following:

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

Answers (1)

Amit Verma
Amit Verma

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

Related Questions