简体   繁体   English

URL重写影响所有asp.net控件的虚拟应用程序根目录

[英]URL Rewrite affecting virtual application root for all asp.net controls

I am using the following rule to map a domain through 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/. 该规则使我可以访问我的网站www.mydomain.co.uk而不是www.mydomain.co.uk/MyDomainFolder/。

The problem is the rule changes the virtual root of my application. 问题是规则更改了我的应用程序的虚拟根目录。 A control with a href="PageTwo.aspx" becomes href="MyDomainFolder/PageTwo.aspx" this also the same when using the tilde: href="~/PageTwo.aspx" becomes href="MyDomainFolder/PageTwo.aspx" 具有href =“ PageTwo.aspx”的控件变为href =“ MyDomainFolder / PageTwo.aspx”,与使用波浪号时相同:href =“〜/ PageTwo.aspx”变为href =“ MyDomainFolder / PageTwo.aspx”

For some reason this seems to prevent response.redirect from working? 由于某种原因,这似乎阻止了response.redirect正常工作?

Does anyone have any ideas how I can fix the links and response.redirect? 有谁知道如何解决链接和response.redirect吗?

What you really seem to need is both a response filter AND a rewrite 您似乎真正需要的是响应过滤器和重写

if you are using IIS 7 the URLRewrite plugin supports this two way rewriting: 如果您使用的是IIS 7,则URLRewrite插件支持以下两种重写方式:

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

they refer to them as inbound (rewrite) and outbound (response filtering) rules 他们将它们称为入站 (重写)和出站 (响应过滤)规则

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM