Rewrite url affecting virtual app root for all asp.net controls

I am using the following rule to map a domain to a subfolder in my shared hosting environment:

<rule name="mydomain.co.uk">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^www.mydomain.co.uk$" />
<add input="{HTTP_HOST}" pattern="^mydomain.co.uk$" />
</conditions>
<action type="Rewrite" url="MyDomainFolder/{PATH_INFO}" />
</rule>

      

This rule allows me to access my website at www.mydomain.co.uk instead of www.mydomain.co.uk/MyDomainFolder/.

The problem is that the rule changes the virtual root of my application. Controlling with href = "PageTwo.aspx" becomes href = "MyDomainFolder / PageTwo.aspx", this is the same when using a tilde: href = "~ / PageTwo.aspx" becomes href = "MyDomainFolder / PageTwo.aspx"

For some reason, this seems to prevent response.redirect from working?

Does anyone have any ideas how I can fix the links and response.redirect?

+2


source to share


1 answer


What you really need is a response filter and a rewrite

if you are using IIS 7 the URLRewrite plugin supports this two-way rewrite:



http://www.iis.net/download/urlrewrite

they refer to them as inbound (rewrite) and outbound (response filtering)

0


source







All Articles