IIS Rewrite rule - ignore for localhost : <p>I have the following rule which is working well for redirecting my www requests to the root.</p>

<p>However I can't seem to turn it off for localhost. Here is what I have now:</p>

<pre><code>    &lt;rule name="CanonicalHostNameRule1"&gt;
      &lt;match url="(.*)" /&gt;
      &lt;conditions&gt;
        &lt;add input="{HTTP_HOST}" pattern="^example\.com$" negate="true" /&gt;
      &lt;/conditions&gt;
      &lt;action type="Redirect" url="https://example.com/{R:1}" /&gt;
    &lt;/rule&gt;
</code></pre>

<p>I've tried many things including things like:</p>

<pre><code>    &lt;rule name="CanonicalHostNameRule1"&gt;
      &lt;match url="(.*)" /&gt;
      &lt;conditions&gt;
        &lt;add input="{HTTP_HOST}" pattern="^localhost$" negate="true" /&gt;
        &lt;add input="{HTTP_HOST}" pattern="^example\.com$" negate="true" /&gt;
      &lt;/conditions&gt;
      &lt;action type="Redirect" url="https://example.com/{R:1}" /&gt;
    &lt;/rule&gt;
</code></pre>

<p>Could you help? Regexes are my weakness alas</p>
