title: IIS: Use Application Request Routing for URL Rewrite outside of Default Website
body: <p>I'd like to do a URL rewrite in IIS where subdomain is rewritten. For example:</p>
  
  <ul>
  <li><code>www.mycompany.com/api/v1.0</code> gets rewritten to <code>api1.mycompany.com</code></li>
  <li><code>www.mycompany.com/api/v2.0</code> gets rewritten to <code>api2.mycompany.com</code></li>
  </ul>
  
  <p>Note that I'd like to <code>rewrite</code> and not <code>redirect</code>, in other words, the URL in the browser remains <code>www.mycompany.com/api/v1.0</code> and <code>www.mycompany.com/api/v2.0</code>.</p>
  
  <p>Any request that doesn't fit the patterns above should continue to be processed by <code>www.mycompany.com</code>.</p>
  
  <p>My understanding is the URL Rewrite 2.0 module alone isn't enough to make this happen, so I installed Application Request Routing 3.0.  Here is the web.config for what I'm trying to do:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;configuration&gt;
      &lt;system.webServer&gt;
          &lt;directoryBrowse enabled="false" /&gt;
          &lt;rewrite&gt;
              &lt;rules&gt;
                  &lt;rule name="API v1.0" stopProcessing="true"&gt;
                      &lt;match url="^api/v1.0/(.*)$" /&gt;
                      &lt;action type="Rewrite" url="http://api1.mycompany.com/{R:1}" /&gt;
                  &lt;/rule&gt;
                  &lt;rule name="API v2.0" stopProcessing="true"&gt;
                      &lt;match url="^api/v2.0/(.*)$" /&gt;
                      &lt;action type="Rewrite" url="http://api2.mycompany.com/{R:1}" /&gt;
                  &lt;/rule&gt;
              &lt;/rules&gt;
          &lt;/rewrite&gt;
      &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Once I installed Application Request Routing, I was able to get this to work, but only if <code>www.mycompany.com</code> is the <code>Default Website</code> for IIS.  In other words, only if IIS is set up as so:</p>
  
  <ul>
  <li>Default Website (<code>www.mycompany.com</code>)
  <ul>
  <li>The web.config for this site is shown above</li>
  </ul></li>
  <li><code>api1.mycompany.com</code></li>
  <li><code>api2.mycompany.com</code></li>
  </ul>
  
  <p>My problem is that <code>www.mycompany.com</code> cannot be the <code>Default Website</code> (the Default Website is reserved by another site on the server).  <code>www.mycompany.com</code> is just another web site just like <code>api1.mycompany.com</code> or <code>api2.mycompany.com</code>.  Is there any way to get this to work without <code>www.mycompany.com</code> being the <code>Default Website</code>?  Something like this?</p>
  
  <ul>
  <li>Default Website (some another non-related website)</li>
  <li><code>www.mycompany.com</code>
  <ul>
  <li>The web.config for this site is as shown above</li>
  </ul></li>
  <li><code>api1.mycompany.com</code></li>
  <li><code>api2.mycompany.com</code></li>
  </ul>