重定向所有子域到新域

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

我想重定向(301)所有流量使用web.config规则一个新的领域,但该网站也被处理子域也将需要重定向的越来越多。

我怎样写为下面的规则?

  • 老域名是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
1个回答
0
投票

啊,我终于得到了它的工作:

    <rule name="redirect" enabled="true">
      <match url="(.*)" />
      <conditions>
        <add input="{HTTP_HOST}" negate="false" pattern="^(.*)\.foo\.com" />
      </conditions>
      <action type="Redirect" url="https://{C:1}.bar.org/{R:1}" appendQueryString="true" redirectType="Permanent" />
    </rule>

我不完全理解的规则,但:/这并不没有如“否定”设置为false工作。

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