title: IIS 7.5 URL Rewrite - Rewrite a Folder from an URL
body: <p>I use IIS 7.5 and URL Rewrite.</p>
  
  <p>I have a website with the following file hierarchy:</p>
  
  <pre><code>webroot
  webroot/LegacySite
  </code></pre>
  
  <p>Both webroot/ and legacy/ are separate App-Folders in IIS.</p>
  
  <hr>
  
  <p>I need to rewrite my URLs so:</p>
  
  <ul>
  <li>If a request is <a href="http://mysite.co/LegacySite/page.aspx" rel="nofollow noreferrer">http://mysite.co/LegacySite/page.aspx</a> the URL will be rewritten to <a href="http://mysite.co/page.aspx" rel="nofollow noreferrer">http://mysite.co/page.aspx</a></li>
  </ul>
  
  <p>Below my <code>Web.Conf</code> (in the webroot folder) does not work properly, could you point out what I'm missing?  </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;configuration&gt;
          &lt;system.webServer&gt;
              &lt;rewrite&gt;
                  &lt;rules&gt;
                      &lt;rule name="MyRole" stopProcessing="true"&gt;
                          &lt;match url=".*" /&gt;
                          &lt;conditions&gt;
                              &lt;add input="{HTTP_HOST}" pattern="^mysite.com" /&gt;
                              &lt;add input="{PATH_INFO}" pattern="^\LegacySite\" negate="true" /&gt;
                          &lt;/conditions&gt;
                          &lt;action type="Rewrite" url="\LegacySite\{R:0}" /&gt;
                      &lt;/rule&gt;
                  &lt;/rules&gt;
              &lt;/rewrite&gt;
          &lt;/system.webServer&gt;
      &lt;/configuration&gt;
  </code></pre>