【问题标题】:Rules url regex规则 url 正则表达式
【发布时间】:2019-03-11 01:53:07
【问题描述】:

我正在创建一个重定向规则

www.<url>.com/overview           to   www.<url>.com/history
www.<url>.com/overview/history   to   www.<url>.com/history

  <rule name="Overview" enabled="true" stopProcessing="true">
    <match url=".*" />
    <conditions>
      <add input="{PATH_INFO}" pattern="^/overview" />
    </conditions>
    <action type="Redirect" url="www.<url>.com/history" appendQueryString="false" />
  </rule>

  <rule name="Overview-History" enabled="true" stopProcessing="true">
    <match url=".*" />
    <conditions>
      <add input="{PATH_INFO}" pattern="^/overview/history" />
    </conditions>
    <action type="Redirect" url="www.<url>.com/history" appendQueryString="false" />
  </rule>

上述规则有效,但有没有办法将两个 url 组合成一个规则,而不是创建两个不同的规则?

提前致谢

【问题讨论】:

    标签: regex redirect rules


    【解决方案1】:

    这行得通吗?

    <add input="{PATH_INFO}" pattern="^/overview(/(history|mission|vision))?$" />
    

    【讨论】:

    • 谢谢我试过这个,但即使 /overview/history/123 或 /overview/history0 正在重定向到 www..com/history
    • 感谢最后一件事,如果我有 /overview/vision 或 overview/mission 并重定向到相同的“www..com/history”页面?
    • @OwaisAhmed:我不明白你的问题。
    • 目前 /overview 和 /overview/history 正在重定向到 www..com/history 但我也希望 /overview/vision 和 overview/mission 被重定向到同一个 www。.com/history
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多