Php Apache将某些子域的安全重定向为不安全

Php Apache将某些子域的安全重定向为不安全,php,apache,mod-rewrite,redirect,subdomain,Php,Apache,Mod Rewrite,Redirect,Subdomain,我有几个具有相同子域的域,这些域可以安全访问,也可以不安全访问。我需要重定向从redirect.somesite.com传入的每个请求,以重定向到安全站点。我需要原始的url,域,如果该网站被要求作为安全与否 http://redirect.site1.com/page?id=1 重定向到 a.site1.com&secure=0 及 https://redirect.site2.com/page?id=2 重定向到 a.site2.com&secure=1 及 http://redirect.

我有几个具有相同子域的域,这些域可以安全访问,也可以不安全访问。我需要重定向从redirect.somesite.com传入的每个请求,以重定向到安全站点。我需要原始的url,域,如果该网站被要求作为安全与否

http://redirect.site1.com/page?id=1

重定向到

a.site1.com&secure=0

https://redirect.site2.com/page?id=2

重定向到

a.site2.com&secure=1

http://redirect.site3.com/page?id=3

重定向到

a.site3.com&secure=0

http://www.site3.com/page?id=3

仍然是


我假设您希望id查询字符串在重定向中匹配

在文档根目录中的.htaccess文件中尝试此操作(或在服务器/vhost配置中,将
^page$
正则表达式更改为
^/page$
):


最后一个规则中的QSA确保“secure=”和原始的“id=”查询字符串参数被附加到URL上。

如何仅将规则应用于以流程子域开始的那些站点,但这似乎是我需要的。
RewriteEngine On

# check if secure= is already set, and set it either to 1 or 0
RewriteCond %{QUERY_STRING} !secure=
RewriteCond %{HTTPS} on
RewriteRule ^page$ /page?%{QUERY_STRING}&secure=1 [L]

RewriteCond %{QUERY_STRING} !secure=
RewriteCond %{HTTPS} off
RewriteRule ^page$ /page?%{QUERY_STRING}&secure=0 [L]

# check if the host starts with a "redirect." and match against the "/page" URI
RewriteCond %{HTTP_HOST} ^redirect\.(.+)$ [NC]
RewriteRule ^page$ https://process.site4.com/page?domain=a.%1 [QSA,R,L]