.htaccess - 从 htaccess 重定向(https 到 http)

标签 .htaccess redirect ssl

我用过这段代码

<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 上转移我,但从 universiti 和商店放在主页上。会是什么?

最佳答案

尝试:

<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>

关于.htaccess - 从 htaccess 重定向(https 到 http),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34267570/

相关文章:

php - .htaccess 所有分页的通用规则

apache - 更改 Apache .htaccess 文件以与 Nginx 一起使用

javascript - 功能未按预期执行。我希望页面切换到 'setup' 但这并没有发生

Apache - 客户端证书

ssl - 自定义域丢包

php - 使用 htaccess 重定向/重写

php - 无法在 codeigniter 3 中加载 css 文件

php - Javascript 重定向 - 用 Php 控制它

apache - htaccess 不能正常工作

AEM6 中的 SSL 配置问题