2016-11-26 120 views
0

我在我的htaccess下面的代码,它工作正常:例外HTTP到HTTPS重定向htaccess的

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

,但我有一个derictory,我shouldn`t被重定向,即应被访问通过HTTP ,例如host.com/nossl/...什么应该添加到我的htaccess?谢谢。

回答

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] 
+1

谢谢,似乎很好地工作。 –

+0

很高兴知道它已经解决了,[您可以在答案的左上角点击**勾号**标记答案](http://meta.stackexchange.com/a/5235/160242) – anubhava