【发布时间】:2014-11-25 03:01:06
【问题描述】:
我有一个 public_html,我想强制执行 https,但不包括此文件夹中的某些目录,因为这些文件夹是父目录,其中包含其他未安装 SSL 的域的文件。
我用它来为整个 public_html 强制执行 https
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
但我想排除一些目录,但以下不起作用。
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^site2 [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
谢谢。
【问题讨论】:
-
REQUEST_URI总是以斜杠开头:RewriteCond %{REQUEST_URI} ^/site2 [NC]表示if uri begins with site2... -
只是添加到之前的评论中,您并没有排除 site2,而是将 site2 设置为使用 HTTPS,而其他所有 uri 都会关闭 HTTPS。
标签: apache .htaccess http https