Isapi Rewrite - 在负载均衡器后面的重定向中保留 HTTPS
我正在运行一个具有 2 个独立子域的网站 - 一个用于 HTTP,另一个用于 HTTPS。
http://www.example.com
https://secure.example.com
http://secure.example.com
没有存在且不会解决。
问题在于该站点在处理所有 SSL 的负载平衡器后面运行。 负载均衡器和 Web 服务器之间始终使用 HTTP 进行通信。
因此,当使用 Isapi Rewrite 3(IIS 的 mod_rewrite 克隆)来实现某些重定向时,我遇到了问题。
就 Isapi Rewrite 而言,HTTPS 已关闭 - 因此 secure.example.com
上的重定向失败。
假设我有一条规则:
RewriteRule ^/example/$ /test/ [R=301,L]
如果我向 https://secure.example.com/example/
发出请求,我希望最终得到 https://secure.example.com/test/
但是,由于 Isapi Rewrite 将 HTTPS 视为关闭,我最终会访问 http://secure.example .com/test/
。
如果域名是 secure.example.com
,有什么方法可以强制重定向到 HTTPS?
类似的事情是:
RewriteCond %{SERVER_NAME} secure.example.com
RewriteRule ^/(.*)$ https://secure.example.com/$1
除了不起作用 - 它立即强制显式重定向,而我想继续处理其他RewriteRules
。
谢谢,
斯图
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://secure.example.com
does not exist and will not resolve.
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.
So, when using Isapi Rewrite 3 (a mod_rewrite clone for IIS) to implement some redirects I'm running into a problem.
As far as Isapi Rewrite is concerned HTTPS is turned off - so redirects on secure.example.com
are failing.
Say I have a rule which says:
RewriteRule ^/example/$ /test/ [R=301,L]
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/
.
Is there any way I can force redirects to be to HTTPS if the domain is secure.example.com
?
Something along the lines of this:
RewriteCond %{SERVER_NAME} secure.example.com
RewriteRule ^/(.*)$ https://secure.example.com/$1
Except that doesn't work - it immediately forces an explicit redirect, whereas I want to continue processing other RewriteRules
.
Thanks,
Stu
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像这样怎么样:
How about smth like this: