我希望我的域名主页被重定向到我的一个 mvc 目录
这是我使用的规则
<rule name="Home" stopProcessing="true">
<match url="^/*$" />
<action type="Rewrite" url="/test/" logRewrittenUrl="true" />
</rule>
如果我放置重定向,同样的规则也有效。但是重写不起作用。
其他网址应正常投放。只应重写主页
我们可以在没有 ARR 的情况下实现这一目标吗?
//www.example.com 应重写为//www.example.com/test/
www.example.com/buy 应该按原样供应。
您的正则表达式不正确。正确的规则是:
<rule name="Home" stopProcessing="true">
<match url="^$" />
<action type="Rewrite" url="/test/" logRewrittenUrl="true" />
</rule>
此规则将在没有 ARR 的情况下起作用,因为您重写到同一网站的子文件夹。如果要重写到 IIS 中的其他网站,则需要 ARR。