【问题标题】:IIS web.config redirect rule for specific URL but not others特定 URL 的 IIS web.config 重定向规则,而不是其他 URL
【发布时间】:2017-02-28 15:45:25
【问题描述】:

我想在 web.config 文件中添加重定向规则http://myurl.com/path/to/old 给http://myurl.com/path/to/new

但是http://myurl.com/fr/path/to/old

http://myurl.com/cn/path/to/old

应该保持不变。我如何通过匹配/规则实现这一目标?

【问题讨论】:

标签: asp.net asp.net-mvc iis web-config


【解决方案1】:

将此添加到您的 web.config:

<rewrite>
  <rules>
    <rule name="Redirect old to new" stopProcessing="true">
      <match url="^path/to/old" ignoreCase="false" />
      <conditions>
        <add input="{URL}" pattern="^fr/.*" ignoreCase="false" negate="true" />
        <add input="{URL}" pattern="^cn/.*" ignoreCase="false" negate="true" />
      </conditions>
      <action type="Rewrite" url="/path/to/new" />
    </rule>
  </rules>
</rewrite>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-07
    • 1970-01-01
    • 2017-05-01
    • 2014-04-06
    • 1970-01-01
    • 1970-01-01
    • 2015-07-09
    • 2012-05-27
    相关资源
    最近更新 更多