问题
I would like to remove my SSL
only for one folder.
My url is https://www.example.com
and I would like to remove https for my interactive PDF https://www.example.com/catalog2017
because https does not work with my interactive PDF.
I tried with .htaccess
but not work.
回答1:
You can use the following rules in your .htaccess
file. What this does is first check if HTTPs is not on, if not, then it will forward everything to HTTPs except for the directory catalog2017
. The second rule checks if HTTPs is on, if so then it will redirect catalog2017
back to HTTP.
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-SSL} !on
RewriteCond %{REQUEST_URI} !^\/(catalog2017)
RewriteRule (.*) https://%{HTTP_HOST}/$1 [L,R=301]
RewriteCond %{HTTP:X-Forwarded-SSL} =on
RewriteCond %{REQUEST_URI} ^\/(catalog2017)
RewriteRule (.*) http://%{HTTP_HOST}/$1 [L,R=301]
Make sure you clear your cache before testing this. If you have problems with the above rule, then you can also try the following:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/catalog2017
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/catalog2017
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
来源:https://stackoverflow.com/questions/43114498/ssl-exception-for-single-folder