问题描述
我正在运行一个有2个独立子域的站点 - 一个用于HTTP,另一个用于HTTPS。
I'm running a site which has 2 separate sub-domains - one for HTTP and another for HTTPS.
-
http://www.example.com
-
https://secure.example.com
http://www.example.com
https://secure.example.com
http://secure.example.com
不存在并且无法解决。
http://secure.example.com
does not exist and will not resolve.
问题是该网站正在负责处理所有SSL的负载均衡器后面运行。始终在HTTP中负载均衡器和Web服务器之间的通信。
The problem is that the site is running behind a load balancer which handles all SSL. Communication between the load balancer and the web servers in always HTTP.
因此,当使用Isapi Rewrite 3(IIS的mod_rewrite克隆)实现某些重定向时,我正在运行问题。
So, when using Isapi Rewrite 3 (a mod_rewrite clone for IIS) to implement some redirects I'm running into a problem.
就Isapi Rewrite而言,HTTPS已关闭 - 因此重定向 secure.example.com
失败。
As far as Isapi Rewrite is concerned HTTPS is turned off - so redirects on secure.example.com
are failing.
说我有一条规则说:
RewriteRule ^/example/$ /test/ [R=301,L]
如果我制作请求 https://secure.example.com/example/
我想结束 https://secure.example.com/test/
但是,因为Isapi Rewrite认为HTTPS为OFF,我最终选择 http:/ /secure.example.com/test/
。
If I make a request for https://secure.example.com/example/
I would like to end up on https://secure.example.com/test/
but, because Isapi Rewrite sees HTTPS as OFF, I end up on http://secure.example.com/test/
.
有什么办法可以强制重定向到HTTPS,如果域名是 secure.example.com
?
Is there any way I can force redirects to be to HTTPS if the domain is secure.example.com
?
有些内容如下:
RewriteCond %{SERVER_NAME} secure.example.com
RewriteRule ^/(.*)$ https://secure.example.com/$1
除非不起作用 - 它会立即强制显式重定向,而我想继续处理其他 RewriteRules
。
Except that doesn't work - it immediately forces an explicit redirect, whereas I want to continue processing other RewriteRules
.
谢谢,
Stu
推荐答案
这样的smth怎么样:
How about smth like this:
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^secure\.mydomain\.com$ [NC]
RewriteRule ^/example/$ https://secure.mydomain.com/test/ [R=301,L]
这篇关于Isapi Rewrite - 在负载均衡器后面的重定向中保留HTTPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!