除了特定页面之外,通过 htaccess 将整个站点重定向到 https

Redirecting whole site to https via htaccess apart from specific pages

我有这个代码:

RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} !\.(jpe?g|gif|bmp|png|ico|js|css)$ [NC]
RewriteRule !^billing(/.*)?$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NC,NE]

如果他们尝试使用 https.[=17= 访问 billing/ 区域之外的任何内容,这目前会将其重定向到 http 等效区域]

但是我想知道如何将其他页面添加到允许通过 https 加载的 "whitelist" 页面?

有问题的两个是:

但是它们都可能在末尾有 查询参数

有人可以解释一下如何添加允许从 https 访问的上述内容,以便下次我想添加内容时知道吗?

您无需担心查询字符串,它们会在请求 URI 之外匹配。您可以添加附加条件:

RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} !\.(jpe?g|gif|bmp|png|ico|js|css)$ [NC]

RewriteCond %{REQUEST_URI} !^/billing
RewriteCond %{REQUEST_URI} !^/remote/get_breaks\.php
RewriteCond %{REQUEST_URI} !^/thumbnail\.php

RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NC,NE]

让它更容易阅读。