我想将http重定向到https的两个类别(商店和大学),其他我想重定向到http [英] I want redirect http to https two categories (shop and university), other i want redirect to http

查看:82
本文介绍了我想将http重定向到https的两个类别(商店和大学),其他我想重定向到http的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这不正确,我从商店和大学获得了很多重定向

this don't work true, i get many redirects from shop and university

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

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


</IfModule>

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

</IfModule>

如何进行正确的重定向?

How do I make the right redirects?

推荐答案

您可以使用:

<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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆