title: IIS Url Rewrite Not Working - 404 Error
body: <p>I'm using the URL Rewrite feature in IIS7. I have set up a website on port 80 with some URL rewrite rules.</p>
  
  <p>The first rule needs to point to a web application on port 8090 and the other rule needs to point to a web application on port 8091. </p>
  
  <p>The rules need to be configured so that:</p>
  
  <ol>
  <li><code>http://localhost/</code> rewrites to <code>http://localhost:8090</code></li>
  <li><code>http://localhost/test</code> rewrites to <code>http://localhost:8091</code>.</li>
  </ol>
  
  <p>Here is the rules that I'm using:</p>
  
  <pre><code>&lt;system.webServer&gt;
      &lt;rewrite&gt;
          &lt;rules&gt;
              &lt;clear /&gt;
              &lt;rule name="Site2" enabled="true" stopProcessing="true"&gt;
                  &lt;match url="^.*/test/.*" /&gt;
                  &lt;conditions logicalGrouping="MatchAll" trackAllCaptures="false" /&gt;
                  &lt;action type="Rewrite" url="http://{HTTP_HOST}:8091/{R:0}" /&gt;
              &lt;/rule&gt;
              &lt;rule name="Site1" enabled="true" stopProcessing="true"&gt;
                  &lt;match url=".*" /&gt;
                  &lt;conditions logicalGrouping="MatchAll" trackAllCaptures="false" /&gt;
                  &lt;action type="Rewrite" url="http://{HTTP_HOST}:8090/{R:0}" /&gt;
              &lt;/rule&gt;
          &lt;/rules&gt;
      &lt;/rewrite&gt;
  &lt;/system.webServer&gt;
  </code></pre>
  
  <p>I'll mention that the "Site1" rule is working. If I go to <code>http://localhost/</code>, I am presented with the web application hosted on port 8090. If I go to <code>http://localhost/test</code>, I am presented with a 404 error.</p>