开发者

Rewriting a domain name so it is handled by a different server binding... Is it possible?

开发者 https://www.devze.com 2023-01-11 20:36 出处:网络
I would like to rewrite a subdomain so it is passed as a querystring to a site. Take the following scenario.

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"
"sub开发者_如何学运维2.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?


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消