【发布时间】:2019-02-04 19:40:15
【问题描述】:
我想使用 web.config 规则将所有流量重定向 (301) 到新域,但该站点还处理越来越多的子域列表,这些子域也需要重定向。
如何为以下内容编写规则?
- 旧域名是 foo.com
- 新域是 bar.org
- 域 (foo.com) 之前和之后的所有内容都需要重定向到新域:
a.foo.com -> a.bar.org
b.foo.com -> b.bar.org
c.foo.com/some-page -> c.bar.org/some-page
d.foo.com/some/other/page -> d.bar.org/some-page
基本上类似于this,但用于 IIS。
这是我目前的尝试:
<rule name="redirect" enabled="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" negate="true" pattern="^(.*)\.foo\.com$" />
</conditions>
<action type="Redirect" url="http://{C:1}.bar.org/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
【问题讨论】:
-
那里的大多数示例似乎都需要访问我没有的 IIS(只能使用 web.config 文件),并且它们也不包括我正在尝试的情况的示例解决。
-
@LexLi 感谢 - 最后,该指南确实提供了帮助。
标签: iis web-config