title: Change the URL root path in ASP.NET MVC or IIS
body: <p>I'm working with a server with a custom URL: <a href="http://example.com/site/" rel="noreferrer">http://example.com/site/</a> and as you can see I need to change the default root path ("/") of my application to prevent 404 errors. Using IIS rewrite module with a outbound rule seems to work, with all html links and references being converted properly to query the internal website. The problem is when a <code>Redirect()</code> or <code>RedirectToAction()</code> method is used in my controllers, the internal name of the website is dropped so a 404 is caused. This is my IIS outbound rule:</p>
  
  <pre><code>&lt;rewrite&gt;
    &lt;outboundRules&gt;
      &lt;rule name="Add path prefix to urls" stopProcessing="true"&gt;
        &lt;match filterByTags="A, Form, Img, Link, Script" pattern="^/(.*)" /&gt;
        &lt;action type="Rewrite" value="/site{R:0}" /&gt;
      &lt;/rule&gt;
    &lt;/outboundRules&gt;
  &lt;/rewrite&gt;
  </code></pre>
  
  <p>So to clarify: I have <a href="http://example.com/site/" rel="noreferrer">http://example.com/site/</a> when a redirection occurs to Account/Login, it becomes <a href="http://example.com/account/login" rel="noreferrer">http://example.com/account/login</a> instead of <a href="http://example.com/site/account/login" rel="noreferrer">http://example.com/site/account/login</a> . I guess the RouteConfig has to be tinkered with but I don't know how, or if I can do this in IIS. I have the following in my RouteConfig class:</p>
  
  <pre><code>routes.MapRoute(
      name: "SiteRoot",
      url: "site/{controller}/{action}",
      defaults: new { controller = "Home", action = "Index" }
  );
  
  routes.MapRoute(
      name: "Default",
      url: "{controller}/{action}",
      defaults: new { controller = "Home", action = "Index" }
  );
  </code></pre>
  
  <p>Thank you.</p>