views:

20

answers:

3

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?

A: 

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.

Pierre 303
+1  A: 

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.

Michael Gorsuch
A: 

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.

JohannesH