首页 > 代码库 > 301 redirect Domain Name using global.asax

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 hereHttpContext.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"));}}

301 redirect Domain Name using global.asax