【问题标题】:IIS URL redirection - igonre match all for some URLsIIS URL 重定向 - 忽略某些 URL 的全部匹配
【发布时间】:2019-05-30 01:19:54
【问题描述】:

我不得不将以前的 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 模式?

提前致谢。

【问题讨论】:

  • 我在末尾添加了 ^ 标记。它将允许我的第二个 URL 但不执行重定向:(

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


【解决方案1】:

不能确定,但​​您是否尝试像那样添加括号?

&lt;match url="^(hotels)/(.*)" /&gt;

我们为特定的通配符重定向做到了这一点:

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

希望对你有帮助!

【讨论】:

  • 是的,我添加了括号来匹配这样的 URL
猜你喜欢
  • 1970-01-01
  • 2016-11-18
  • 2019-10-20
  • 1970-01-01
  • 2013-01-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-04-03
相关资源
最近更新 更多