【问题标题】:redirect from htaccess (https to http)从 htaccess 重定向(https 到 http)
【发布时间】:2015-12-14 22:10:48
【问题描述】:

我使用了这个代码

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{HTTPS} off
    RewriteRule ^(shop|university)(/.*)?$ https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L]

    RewriteCond %{HTTPS} on
    RewriteRule !^(shop|university)(/.*)?$ http://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L]

</IfModule>

我想将http重定向到https两个类别(商店和大学),其他我想重定向到http

但是,在将规则安装到所有 https 后,我在 http 上转移了我,但从大学和商店放在了主页上。会是什么?

【问题讨论】:

    标签: .htaccess redirect ssl


    【解决方案1】:

    试试:

    <IfModule mod_rewrite.c>  
    
    
        RewriteEngine On
    
       #https to http    
        RewriteCond %{HTTPS} ^on$
        RewriteCond %{REQUEST_URI} !^/(shop|university)/      
       RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L]
    
    
       #http to https
        RewriteCond %{HTTPS} ^off$
        RewriteCond %{REQUEST_URI} ^/(shop|university)/      
       RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L]
    
    
    
    </IfModule>
    

    【讨论】:

    猜你喜欢
    • 2017-07-18
    • 2019-04-11
    • 1970-01-01
    • 2014-04-16
    • 2012-11-02
    • 2018-08-25
    • 1970-01-01
    • 2019-06-23
    相关资源
    最近更新 更多