How to redirect a subdomain to a subdirectory - Aps.net Example

Discussion in 'General troubleshooting' started by mgshortt, May 18, 2011.

  1. Put it in your Page_Load method.

    C#
    if (((Request.ServerVariables["SERVER_NAME"].ToUpper().IndexOf("subdomain2.YourHostedDomainName.com".ToUpper()) + 1) > 0))
    {
    Response.Redirect("/subdomain1");
    }
    else if (((Request.ServerVariables["SERVER_NAME"].ToUpper().IndexOf("subdomain2.YourHostedDomainName.com".ToUpper()) + 1) > 0))
    {
    Response.Redirect("/subdomain2");
    }
    else if (((Request.ServerVariables["SERVER_NAME"].ToUpper().IndexOf("subdomain3.YourHostedDomainName.com".ToUpper()) + 1) > 0))
    {
    Response.Redirect("/subdomain3/home.asp");
    }
     

Share This Page