IIS7 url rewrite rules

Posted by sympatric greg on Server Fault See other posts from Server Fault or by sympatric greg
Published on 2010-06-16T22:23:33Z Indexed on 2010/06/16 22:33 UTC
Read the original article Hit count: 690

Filed under:
|
|
|

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?

© Server Fault or respective owner

Related posts about iis7

Related posts about subdomain