在我的 web.config 文件中,我希望能够完成以下两个重定向:
重定向根/域: oldsite.org 到 newsite.org/this-is-thenewsite
并且 页面通配符重定向: oldsite.org/any-all-oldpage 至 newsite.org/any-all-oldpage
实现这两者的正确方法是什么?
我目前将所有旧流量重定向到新页面,并且我知道我可以使用 {R0} 或 {R1} 来通配符页面。
我只是不知道进行 TIA 的最佳方法!
您可以使用类似于以下的规则将一个域重定向到另一个域:
<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>