title: Easy IIS 7.5 url rewrite rule (from non-www to www) gives redirect loop error in browser
body: <p>This seems like it should be such a 101-level question but I cannot get it to work.</p>
  
  <p>I very simply need to set up a url rewrite rule that redirects mydomain.com to www.mydomain.com. That's it. But no matter how I go at it, I get a URL redirect error in my browser.</p>
  
  <p>Below are a few different rule definitions I have tried, one-by-one. As far as I can tell, any should work. But none have. I would be incredibly grateful for any insight.</p>
  
  <pre><code>&lt;rule name="non-www to www" enabled="true"&gt;
      &lt;match url=".*" /&gt;
      &lt;conditions&gt;
          &lt;add input="{HTTP_HOST}" pattern="^mydomain.com$" /&gt;
          &lt;add input="{HTTP_HOST}" negate="true" pattern="^www.mydomain.com$" /&gt;
      &lt;/conditions&gt;
      &lt;action type="Redirect" url="http://www.mydomain.com/{R:0}" redirectType="Permanent" /&gt;
  &lt;/rule&gt;
  
  &lt;rule name="non-www to www" enabled="true"&gt;
      &lt;match url=".*" /&gt;
      &lt;conditions&gt;
          &lt;add input="{HTTP_HOST}" pattern="^www\." negate="true" /&gt;
      &lt;/conditions&gt;
      &lt;action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" /&gt;
  &lt;/rule&gt;
  
  &lt;rule name="non-www to www" enabled="true"&gt;
      &lt;match url=".*" /&gt;
      &lt;conditions&gt;
          &lt;add input="{HTTP_HOST}" pattern="^[^\.]+\.[^\.]+$" /&gt;
      &lt;/conditions&gt;
      &lt;action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" /&gt;
  &lt;/rule&gt;
  </code></pre>