web.config 旧站点到新站点 301,域/根到新页面,旧页面到旧页面

问题描述 投票:0回答:1

在我的 web.config 文件中,我希望能够完成以下两个重定向:

重定向根/域: oldsite.org 到 newsite.org/this-is-thenewsite

并且 页面通配符重定向: oldsite.org/any-all-oldpage 至 newsite.org/any-all-oldpage

实现这两者的正确方法是什么?

我目前将所有旧流量重定向到新页面,并且我知道我可以使用 {R0} 或 {R1} 来通配符页面。

我只是不知道进行 TIA 的最佳方法!

redirect web-config root wildcard-mapping
1个回答
0
投票

您可以使用类似于以下的规则将一个域重定向到另一个域:

<rule name="Redirect" stopProcessing="true">
  <match url="(.*)" />
  <conditions>
    <add input="{HTTP_HOST}" pattern="^oldsite.org$" />
  </conditions>
  <action type="Redirect" url="https://newsite.org/{R:0}" redirectType="Permanent" />
</rule>

来源:Web.config 使用重写规则进行重定向 - https、www 等

© www.soinside.com 2019 - 2024. All rights reserved.