问题
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
but 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?
回答1:
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>
来源:https://stackoverflow.com/questions/42513071/iis-web-config-redirect-rule-for-specific-url-but-not-others