1

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.

2
  • 1
    take out the condition Oct 1, 2015 at 6:15
  • Works! Sure is a more simple way to look at this... If you put your comment as an answer I'll mark it as accepted.
    – Howiecamp
    Oct 2, 2015 at 22:13

1 Answer 1

2

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .