Sunday 16 March 2008

Redirect Subdomains with ASP.NET and C#

How to do sub domain redirection with asp.net c#

string strServerName = Request.ServerVariables["SERVER_NAME"].ToString().ToUpper();

if (strServerName.IndexOf("subdomain1.domain.com") > -1)
{
Response.Redirect("/subdomain1");
}
else if ....

1 comment:

Unknown said...

If you change it to upper case, you should check for upper case using instr (I think).

.ToUpper()
SUBDOMAIN1.DOMAIN.COM

http://www.nba-stats.com