user2192094
user2192094

Reputation: 337

How to redirect entire website on HTTPS except 2 subdirectories?

I would like to redirect my entire site to start with HTTPS except 2 subdirectories that I wish to keep on HTTP.

I tried the following but to no avail. Please advice.

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/north/index.html$
RewriteCond %{REQUEST_URI} !^/south/index.html$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Upvotes: 0

Views: 30

Answers (1)

Panama Jack
Panama Jack

Reputation: 24468

Try and have you rules like this

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/(north|south)(/.*)? [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Upvotes: 2

Related Questions