I have a website whose name I am changing from example.com to newexample.com. My thought process (please comment on this as well, as my approach may be incorrect) was to configure permanent a redirect from http:(s)://.example.com/ (I am not using '' in the literal regex sense here) to https://www.newexample.com/.
In the rewrite rules section I took the following approach:
<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>
The way I understand the above rules is that ANY host name will get redirected to "https://www.newexample.com/whatever", leaving all other aspects of the requested url as-is, but I am not getting redirected using any combination that I've tried so far.
Remove the whole
conditions
node from your rule.You have the same pattern in the condition as in the rule which makes it redundant, except for the
negate="true"
attribute which is the reason why it didn't work.The rule matches everything, but then the condition blocks everything, so nothing is redirected.
Only use conditions if you really need them to further limit requests matched by the rule.