更新时间:2023-10-21 19:28:58
尝试添加像一个条件:
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTPS}:s on:(s)
哪些检查,要么HTTPS已关闭或它在,你可以使用反向引用来获取S字符:
Which checks that either HTTPS is off or it's on and you can use a backreference to fetch the "s" character:
RewriteCond %{HTTP_HOST} ^sub.domain.com$ [NC]
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTPS}:s on:(s)
RewriteRule ^ http%1://sub.domain.com:2368%{REQUEST_URI} [P,QSA,L]
因此,如果HTTPS是关闭的,%1
是空白的,该协议是的http://
。如果HTTPS上,那么S进行分组和%1
反向引用是一个S,因此协议是 https://开头
。
So if HTTPS is off, %1
is blank and the protocol is http://
. If HTTPS is on, then the "s" is grouped and the %1
backreference is an "s", thus the protocol is https://
.
然而,这一切假设端口2368可以处理的两个的未加密和SSL / TLS。
However, this is all assuming that port 2368 can handle both unencrypted and SSL/TLS.