我想重定向(301)所有的流量到一个新的域使用web.config规则,但网站也处理一个不断增长的子域列表,这也将需要重定向。
如何为下列事项编写规则?
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>发布于 2019-02-04 11:40:15
啊,我终于让它起作用了:
<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,它就无法工作。
https://stackoverflow.com/questions/54482562
复制相似问题