Force https except for one directory

2019-02-20 19:25发布

问题:

I'm using the following .htaccess file to force any page request to https://

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

How could I force https for all directories/pages except the directory "/domain" ?

I can change the main htacces or create a new one in the /domain directory, the easy way, but how?

回答1:

This should get what you need.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !domain [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]