-1

I have a IIS URL - re-writing rule that makes sure all the urls have www. -

<rule name="Add www" patternSyntax="Wildcard" stopProcessing="true">
          <match url="*" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="www.example.com" negate="true" />
          </conditions>
          <action type="Redirect" url="https://www.example.com/{R:1}" />
</rule>

This works in production the way I want it to.

However I have a local version of my website set up on my development machine that looks like http://mydomain.local

When I run my local version of the website and go to mydomain.local I get redirected to www.example.com

How can I make the rule ignore my local development URL?

Ayo Adesina
  • 2,231
  • 3
  • 37
  • 71

1 Answers1

0

You can try to add a condition to ignore the local development URL.

<rule name="Add www" patternSyntax="Wildcard" stopProcessing="true">
      <match url="*" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="www.example.com" negate="true" />
        <add input="{HTTP_HOST}" pattern="http://mydomain.local" negate="true" />
      </conditions>
      <action type="Redirect" url="https://www.example.com/{R:1}" />
</rule>

Best regards,

Sam

samwu
  • 3,857
  • 3
  • 11
  • 25