特定URL的IIS web.config重定向规则,而非其他URL [英] IIS web.config redirect rule for specific URL but not others

查看:67
本文介绍了特定URL的IIS web.config重定向规则,而非其他URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将重定向规则添加到web.config文件 http://myurl.com/路径/到/旧 http://myurl.com/path/to/new

I want to add a redirect rule to the web.config file http://myurl.com/path/to/old to http://myurl.com/path/to/new

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

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

应保持不变.如何通过匹配/规则实现?

should stay the same. how can i achieve that with match/rule?

推荐答案

将此添加到您的web.config:

Add this to your 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>

这篇关于特定URL的IIS web.config重定向规则,而非其他URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆