我想在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
应该保持不变。我如何通过匹配/规则实现这一目标?
答案 0 :(得分: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>