IIS7 url rewrite rules
- by sympatric greg
In a hosted environment, I will be utilizing subdomains (and virtual directories) for various coding projects. I have a rewrite rule that changes 'subdomain.domain.com/url' to 'domain.com/subdomain/url'.
This worked fine, except that the browser couldn't find resources with paths generated by ResolveURL("~/something").
The server was using the Application Path of "/subdomain/" so based on the rewrite rule, the browser's request for "/subdomain/something" was being looked for in "/subdomain/subdomain/something" were it wasn't to be found.
either of these urls were valid:
http://www.domain.com/subdomain/something
http://subdomain.domain.com/something
I resolved this by adding a another url rewrite rule to the subdomain:
<rule name="RemoveSuperDir">
<match url="subdomain/(.*)" />
<action type="Rewrite" url="{R:1}" />
</rule>
So for each subdomain that I might add, I will need to add such a rule. Is there a way to write a single rule at the domain level to resolve this issue?