【发布时间】:2013-06-02 15:46:54
【问题描述】:
这是我部署的内容:
testRedirect 是一个空网站。所有子应用程序都是在应用程序中转换的子文件夹。它们都是 ASP .Net MVC 网站。
这是我要设置的内容:
Http://localhost/必须显示SiteName1的内容 在地址栏中显示Http://localhost/SiteName1/(必须 留Http://localhost/)Http://localhost/SiteName1/必须显示SiteName1的内容 不在地址栏中显示Http://localhost/SiteName1/(必须保持Http://localhost/)Http://localhost/SiteName2/显示SiteName2的内容和 在地址栏中显示Http://localhost/SiteName2/(SiteName3&SiteName4和任何其他网站的行为相同......)
换句话说,我希望我的SiteName1 像一个主页网站
到目前为止,我所尝试的与@cheesemacfly here 提供的答案类似:
<rules>
<rule name="Redirect if SiteName1" stopProcessing="true">
<match url="^SiteName1/(.*)$" />
<action type="Redirect" url="{R:1}" />
</rule>
<rule name="Rewrite to sub folder">
<match url="^.*$" />
<action type="Rewrite" url="SiteName1/{R:0}" />
</rule>
</rules>
它适用于案例 1 和 2,但不适用于其他案例。
我尝试添加这样的规则,但是没有成功...
<rule name="if_not_SiteName1" stopProcessing="true">
<match url="^SiteName1/(.*)$" negate="true" />
<action type="None" />
</rule>
【问题讨论】:
-
您是否使用任何路由系统?因为如果不是,您可以使用
IsFile/IsDirectory条件(因此,如果请求的路径,假设http://localhost/SiteName2/default.aspx或http://localhost/SiteName2/指向一个真实的文件/文件夹,那么您不会触发规则)。它适用于你的情况吗? -
@cheesemacfly 我确实使用路由,这些是 ASP .Net MVC 站点。我已经更新了我的问题。
标签: url iis url-rewriting rewrite url-rewrite-module