web.config将非www重定向到带有一个路由异常的www

时间:2017-10-26 07:51:03

标签: asp.net iis web-config url-redirection

您好我无法使用重定向规则配置我的web.config文件。

我的重定向规则现在是

<rule name="Redirects to www.example.com" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAny">
    <add input="{HTTP_HOST}" pattern="^example.com$" />

</conditions>
<action type="Redirect" url="https://www.example.com/{R:0}" />

现在我想从上面提到的规则中排除网址https://example.com/some-url(以及此网站下的所有网址)。此规则不应将https://example.com/some-url重定向到https://www.example.com/some-url

那么如何从重定向规则中排除此网址。

1 个答案:

答案 0 :(得分:0)

你不能只添加这样的条件(注意:现在编辑):

<add input="{REQUEST_URI}" pattern="/some-url/(.*)" negate="true" />

到条件列表?

编辑:并将条件设置为“MatchAll”而不是“MatchAny”

未经测试,但似乎可能有用吗?

(注:编辑答案为第一条规则绝对错误;当前版本可能有效,但仍未经测试)