You are Here: FAQ ->Scripting & Programming->ASP .Net->Article #10


WebHosting Microsoft-Edition This Article is for 1&1 Microsoft Web Hosting Only.


Redirecting to a different website or a folder using asp.net



The following example redirects s119712208.websitehome.co.uk to http://1and1.co.uk and usa-test.com to usa-test.com/www/index.htm (redirecting to a different folder)

<script runat="server" Language="c#">
public void Page_Init(Object Src, EventArgs E)
{
	switch((Request.ServerVariables["HTTP_HOST"]).Replace("www.",""))
 	{
 		case "s119712208.websitehome.co.uk":
 			Response.Redirect("http://1and1.co.uk");
 			break;
		case "usa-test.com":
 			Response.Redirect("http://usa-test.com/www/index.htm");
 			break;
		default:
			Response.Redirect("http://1and1.co.uk");
			break;
	}
}
</script>


Print Article
How useful was this article?
(From 5 = Very Useful to 1 = Not Very Useful at all):
1 2 3 4 5