我有附加的重定向和重写规则。基本上,www.foo.com/vehicles/vehicle-detail.aspx?stockno=123456被重写为www.foo.com/123456。这符合我所制定的规则的预期。现在,如果我尝试浏览不存在的页面(即www.foo.com/test.aspx),则重写规则有资格,IIS尝试将请求转发到www.foo.com/vehicles/vehicle-detail。 aspx(没有查询字符串)。在vehicle-detail.aspx页面中,如果querystring中没有有效的stockno,那么我有代码重定向到主页,所以这就是发生了什么。我不知道如何纠正规则,以免条件不符合规定。我附加了失败请求跟踪的规则和屏幕截图,使我能够查看请求/重写规则。URL重写模块IIS7不正确处理重写规则
<rule name="Redirect StockNo" enabled="true" stopProcessing="true">
<match url="^Vehicles/Vehicle-Detail\.aspx$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern="^stockno=([^=&]+)$" />
</conditions>
<action type="Redirect" url="{C:1}" appendQueryString="false" />
<rule name="Rewrite StockNo" enabled="true" stopProcessing="true">
<match url="^([^/]+)/?$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="Vehicles/Vehicle-Detail.aspx?stockno={R:1}" />
非常感谢。你的回应让我想到如何配置我需要的东西。谢谢!! – obautista