UPDATE: rewording for conciseness...
With an ASP.NET MVC project, is it possible to have web.config rewrite rules take precedence over MVC's RegisterRoutes()
call OR can IgnoreRoute
be called for just a specific domain?
I have a single MVC application that accepts traffic over multiple domains (mydomain.com and otherdomain.com), the application serves different content based on the requested host (i.e. it's multi-tenant).
I have a URL rewrite (a reverse proxy) configured in web.config which should only apply to a specific host:
<rule name="Proxy" stopProcessing="true">
<match url="proxy/(.*)" />
<action type="Rewrite" url="http://proxydomain.com/{R:1}" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^(mydomain\.com|www\.mydomain\.com)$" />
</conditions>
<serverVariables>
<set name="HTTP_X_UNPROXIED_URL" value="http://proxydomain.com/{R:1}" />
<set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}" />
<set name="HTTP_X_ORIGINAL_HOST" value="{HTTP_HOST}" />
<set name="HTTP_ACCEPT_ENCODING" value="" />
</serverVariables>
</rule>
However, an MVC application will seemingly only honor web.config configured routes if they're ignored from the application's RegisterRoutes()
method with:
routes.IgnoreRoute("proxy");
Which then, unfortunately, applies the ignore to both domains. Suggestions greatly appreciated...