重写域名,以便由不同的服务器绑定处理......这可能吗?
我想重写一个子域,以便将其作为查询字符串传递到站点。采取以下场景。
IIS 配置:
站点 A(绑定:*, site-a.com)
站点 B(绑定:site-b.com)
重写规则:
"sub1.site-a.com" -- rewrite to -> "site-a.com"
"sub2.site-a.com" -- rewrite to -> "site-a.com"
"sub1.site-b.com" -- rewrite to -> "site-b.com?subdomain=sub1"
"sub2.site-b.com" -- rewrite to -> "site-b.com?subdomain=sub2"
如果我在 IIS 服务器设置中制定重写规则,site-a.com 将捕获所有重写,因为原始 url 与 site-a.com 上的默认绑定匹配而不是将绑定与重写的 url 进行匹配。有什么办法可以解决这种行为吗?
I would like to rewrite a subdomain so it is passed as a querystring to a site. Take the following scenario.
IIS Config:
Site A (bindings: *, site-a.com)
Site B (bindings: site-b.com)
Rewrite rules:
"sub1.site-a.com" -- rewrite to -> "site-a.com"
"sub2.site-a.com" -- rewrite to -> "site-a.com"
"sub1.site-b.com" -- rewrite to -> "site-b.com?subdomain=sub1"
"sub2.site-b.com" -- rewrite to -> "site-b.com?subdomain=sub2"
If I make the rewrite rules in the IIS server settings, site-a.com will capture all the rewrites because the original url match the default binding on site-a.com instead of matching the bindings against the rewritten urls. Is there any way around this behavior?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您要在前面放置一个反向代理(例如 Apache),则可以使用 mod_rewrite 来实现。
我认为在 IIS 中没有任何明确的方法可以做到这一点。
If you were to place a reverse proxy in front, say Apache, this would be possible with mod_rewrite.
I do not think that there is any clear way to do this in IIS as it stands.
您需要两个 IP 地址或在网站中移动部分重定向逻辑。
第二种解决方案可能不可接受,因此获取第二个 IP 地址。这是合理的,所以你得到它不会有任何问题。
You need two IP address or move a part of your redirection logic in the websites.
Second solution may not be acceptable, so get a second IP address. It's justified so you won't have any problem to get it.
解决方案是使用ARR(应用程序请求路由)中的代理。当您使用“http://”编写重写规则时,它将通过 ARR 进行路由。问题解决了。
The solution was to use the proxy in ARR (Application Request Routing). When you write a rewrite rule with "http://" it will be routed through ARR. Problem solved.