重写域名,以便由不同的服务器绑定处理......这可能吗?

发布于 2024-09-14 05:52:32 字数 497 浏览 3 评论 0原文

我想重写一个子域,以便将其作为查询字符串传递到站点。采取以下场景。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

旧情别恋 2024-09-21 05:52:32

如果您要在前面放置一个反向代理(例如 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.

离不开的别离 2024-09-21 05:52:32

您需要两个 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.

冷情妓 2024-09-21 05:52:32

解决方案是使用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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文