简体   繁体   English

http到https中的异常在htaccess中重定向

[英]Exceptions in http to https redirect in htaccess

I have the following code in my htaccess and it works fine: 我的htaccess中有以下代码,它可以正常工作:

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

but I have one derictory, that I shouldn`t be redirected ie should be accessed through http, eg host.com/nossl/... what should add to my htaccess? 但是我有一个问题,我不应该被重定向,即应该通过http进行访问,例如host.com/nossl / ...应该为我的htaccess添加什么? Thanks. 谢谢。

You can use a negative pattern in RewriteRule like this: 您可以在RewriteRule使用负模式,如下所示:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM