单个文件夹的 SSL 例外 [英] SSL exception for single folder
问题描述
我只想删除一个文件夹的 SSL
.
I would like to remove my SSL
only for one folder.
我的网址是 https://www.example.com
我想为我的交互式 PDF https://www.example.com/catalog2017
删除 https,因为 https 不适用于我的交互式 PDF.
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.
我用 .htaccess
试过,但没有用.
I tried with .htaccess
but not work.
推荐答案
您可以在 .htaccess
文件中使用以下规则.它的作用是首先检查 HTTPs 是否未打开,如果未打开,则它将除了目录 catalog2017
之外的所有内容都转发到 HTTPS.第二条规则检查 HTTPs 是否开启,如果开启,则将 catalog2017
重定向回 HTTP.
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]
这篇关于单个文件夹的 SSL 例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!