I have a domain on a shared server and inside it I have some subfolders that are set up as applications in IIS 7. Within the main domain I have created subdomains that redirect to applications / folders.
Ex:
- www.domain.com
- subdomain.domain.com
It worked perfectly with an Asp.net Web Forms application. But I updated the technology for MVC and when I access the application through the url "subdomain.domain.com" MVC is adding the name of the subfolder / application in the url when clicking on an action link. p>
Ex:
- subdomain.domain.com/subdomain/Controller/Acction
and this way the application does not work. only works if I access the application through the url: "www.dominio.host.com.br/App/Controller/Acction" and would still have to change some requests in the code.
I would like the url to appear only:
- subdominio.domain.com.br/Controller/Acction
I have already tried several route options in the code and also tested Rewrite URL as below but nothing worked.
<system.webServer>
.
.
.
<rewrite>
<rules>
<rule name="Remove Virtual Directory">
<match url=".*" />
<action type="Rewrite" url="{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
Suggested Update
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}