首页 > 其他 > 详细

301 redirect Domain Name using global.asax

时间:2014-11-25 18:21:04      阅读:255      评论:0      收藏:0      [点我收藏+]

 

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


}

301 redirect Domain Name using global.asax

原文:http://www.cnblogs.com/dupeng0811/p/4121426.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!