SSL exception for single folder

我们两清 提交于 2019-12-24 01:15:40

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!