【问题标题】:SSL exception for single folder单个文件夹的 SSL 异常
【发布时间】:2017-03-30 21:03:55
【问题描述】:

我只想删除一个文件夹的SSL。

我的网址是https://www.example.com 我想为我的交互式 PDF https://www.example.com/catalog2017 删除 https,因为 https 不适用于我的交互式 PDF。

我尝试使用.htaccess,但不起作用。

【问题讨论】:

    标签: apache .htaccess ssl ssl-certificate prestashop


    【解决方案1】:

    您可以在.htaccess 文件中使用以下规则。它的作用是首先检查 HTTPs 是否未打开,如果没有,则它将所有内容转发到 HTTPs,但目录 catalog2017 除外。第二条规则检查 HTTPs 是否开启,如果开启则将 catalog2017 重定向回 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]
    

    确保在测试之前清除缓存。如果您对上述规则有问题,那么您还可以尝试以下方法:

    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]
    

    【讨论】:

    • 没问题,很高兴能帮上忙 :)
    猜你喜欢
    • 1970-01-01
    • 2015-02-01
    • 1970-01-01
    • 2022-09-23
    • 1970-01-01
    • 2011-12-19
    • 1970-01-01
    • 1970-01-01
    • 2016-10-02
    相关资源
    最近更新 更多