2014-09-28 45 views
0

我正在使用.htaccess將URL從http://轉換爲我的網站中的https://如何將例外添加到.htaccess https地址轉換?

如何在訪問特定文件夾時向.htaccess-file添加異常時不轉換路徑? 對於如 「/ nohttps /」 -folder


我希望發生的事情:

http://example.com   --> https://example.com 
http://example.com/something/ --> https://example.com/shomething/ 
http://example.com/nohttps/ --> http://example.com/nohttps/   ("no rewrite") 

現在

.htaccess文件:

RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 

回答

1

您可以添加第二使用條件RewriteCond

RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteCond %{REQUEST_URI} !^/nohttps 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 
+0

不起作用... 「404錯誤」..試圖訪問「https://www.example.com/nohttps/index.html.var」 – 2014-09-28 19:28:34

+0

@ user2748705好吧現在就試試。請記住,這將僅適用於直接訪問「http://」,訪問地址爲 – 2014-09-28 19:30:01

+0

,地址爲 「http://example.com/nohttps/」 ,並嘗試訪問 「https://example.com/nohttps/index。 html.var「 – 2014-09-28 19:38:32