Loading

301 redirect Domain Name using global.asax

 

void Application_BeginRequest(object sender, EventArgs e)
{


if (HttpContext.Current.Request.Url.ToString().ToLower().Contains("http://domain.com"))
{
// new line here
HttpContext.Current.Response.Clear();
//
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", Request.Url.ToString().ToLower().Replace("http://domain.com", "http://www.domain.com"));
}


}
posted @ 2014-11-25 17:06  Dhoopu  阅读(273)  评论(0编辑  收藏  举报