如何为.htaccess https-address转换添加例外?

时间:2014-09-28 18:27:41

标签: apache .htaccess mod-rewrite

我正在使用.htaccess将网址从http://转换为https://

如何在.htaccess文件中添加例外,以便在访问特定文件夹时不转换路径? 例如" / 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 个答案:

答案 0 :(得分:1)

您可以使用RewriteCond

添加第二个条件
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/nohttps
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}