configurationIIS重写模块以将任何主机名redirect到特定的主机名

我有一个网站,其名称从example.com更改为newexample.com。 我的思考过程(请评论这一点,以及我的方法可能是不正确的)是configuration永久redirect从http:(s):// .example.com / (我不使用字面正则expression意义这里) https://www.newexample.com/

重写规则部分,我采取了以下的方法:

<rewrite> <rules> <rule name="Redirect to newexample.com"> <match url=".*" /> <conditions logicalGrouping="MatchAny"> <add input="{HTTP_HOST}" pattern=".*" negate="true" /> </conditions> <action type="Redirect" url="https://www.newexample.com/{R:0}" redirectType="Permanent"/> </rule> </rules> </rewrite> 

我了解上述规则的方式是,任何主机名将被redirect到“ https://www.newexample.com/whatever ”,离开所请求的url的所有其他方面,但我没有得到redirect使用任何我到目前为止尝试的组合。

从规则中删除整个conditions节点。

你在条件中有相同的模式,使得它是冗余的,除了negate="true"属性,这是它没有工作的原因。

规则匹配所有内容,但条件阻止了所有内容,因此没有任何内容被redirect。

只有使用条件,如果你真的需要他们进一步限制规则匹配的请求。