views:

41

answers:

1

Consider multiple domains (with different country extensions) that go to one singe physical website. Depending on the country extension of the domain, I want to route to a specific subfolder while keeping the active domain!

Examples: www.mydomain.com/we/about-us.aspx to www.mydomain.com/content/com/we/about-us.aspx www.mydomain.fr/we/about-us.aspx to www.mydomain.fr/content/fr/we/about-us.aspx www.mydomain.be/we/about-us.aspx to www.mydomain.be/content/be/we/about-us.aspx

Is this possible with the new web routing features in ASP.NET 4.0?

Thanks,

Nick

A: 

I would check the HTTP_HOST servervariable, and use different rules depending on the domain, like:

void RegisterRoutes(RouteCollection routes)
{
    string domain = HttpContext.Current.Request.ServerVariables["HTTP_HOST"];

    switch (domain)
    {
        case "www.mydomain.com":
           //rules
            break;
        case "www.mydomain.fr":
            //rules
            break;
    }
}
Ethan