IIS 7 URL重写-匹配路径并重定向到同一域中的另一个

时间:2018-11-13 20:50:22

标签: iis url-rewriting

让我们说我想自动重写

http://anysite.com/oldlogin

http://anysite.com/newlogin

我应该如何配置RewriteRules.config? 我尝试过

  <rule name="Redirect to new login" stopProcessing="true">
    <match url="(.*)" />
    <conditions logicalGrouping="MatchAny">
      <add input="{HTTP_HOST}" pattern="http://anysite.com/oldlogin" ignoreCase="true" />
    </conditions>
    <action type="Redirect" url="/newlogin" redirectType="Permanent" />
  </rule>

无济于事。

1 个答案:

答案 0 :(得分:0)

这应该可以解决问题:

<rule name="Redirect to new login" stopProcessing="true">
    <match url="oldlogin"/>
    <action type="Redirect" url="http://anysite.com/newlogin" appendQueryString="false"/>
</rule>

"oldlogin" 可以是任何路径,如 "profile/login" 等