【问题标题】:Exceptions in http to https redirect in htaccesshtaccess 中 http 到 https 重定向的异常
【发布时间】:2016-11-26 13:58:01
【问题描述】:

我的 htaccess 中有以下代码,它工作正常:

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www.host\.com*
RewriteRule ^(.*)$ https://host.com/$1 [L,R=301]

但我有一个错误,我不应该被重定向,即应该通过 http 访问,例如host.com/nossl/... 应该在我的 htaccess 中添加什么?谢谢。

【问题讨论】:

    标签: apache .htaccess ssl https


    【解决方案1】:

    您可以像这样在RewriteRule 中使用否定模式:

    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} ^www.host\.com$ [NC]
    RewriteRule !^nossl(/.*)?$ https://host.com%{REQUEST_URI} [L,R=301,NC,NE]
    
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-10
    • 2017-07-18
    • 2012-11-02
    • 2018-08-25
    • 1970-01-01
    相关资源
    最近更新 更多