9

I have an integrated SSL for my entire site and have placed htaccess code to redirect to https when anyone visits my domain URL. But I want to keep one folder out of this redirection to https. Please help me with this... Below is the htaccess code placed in my root to redirect all requests to https counterpart

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

Thanks

4

1 回答 1

15

只需添加一个条件以排除文件夹:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/folder1
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

如果您想将 SSL 请求重定向到非 SSL for /folder1,那么:

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/folder1
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
于 2013-07-09T04:41:27.383 回答