2016-11-26 142 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