IIS URL重定向-igonre与某些URL全部匹配

时间:2019-01-03 12:41:24

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

我不得不将以前的URL模式更改为其他内容。较早的URL模式是

www.testdomain.com/hotels/“ city”,它更改为www.testdomain.com/hotel-"city“

下面是我使用的重定向。

<rule name="cityChange" patternSyntax="ECMAScript" stopProcessing="true">
  <match url="^hotels/(.*)" />
  <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
    <add input="{HTTP_HOST}" pattern="www.testdomain.com" />
  </conditions>
  <action type="Redirect" url="www.testdomain.com/hotel-{R:1}"appendQueryString="false" redirectType="Temporary" />
</rule>

现在我有另一个问题,这是我在网站上使用的另一个URL,也正在重定向到另一个URL。该网址是

  

www.testdomain.com/hotels/'city'/'name'-'street'-'postalcode'

由于我已经将通配符用于/ hotels /'city'到/ hotel-'city',因此它在URL上方更改为

  

www.testdomain.com/hotel-'city'/'name'-'street'-'postalcode'

也是。但是该URL在站点中无效,并且我不想在那里从“-”替换“ /”。

如何从上面提到的通配符中排除此URL模式?

谢谢。

1 个答案:

答案 0 :(得分:0)

不能确定是否可以,但是您是否尝试添加括号?

<match url="^(hotels)/(.*)" />

我们针对特定的通配符重定向进行了此操作:

<rule name="modeles-en" enabled="true" stopProcessing="true">
  <match url="^(modeles-en)/(.*)" ignoreCase="true" />
  <action type="Redirect" url="/models/{R:2}" redirectType="Permanent" />
</rule>

希望有帮助!