301跳转可以把网址权重传递集中到规范化网址中,网上也有讲很多种跳转方法,这里记一下Global.asax的Application_BeginRequest 方法中写,下面举例子输入xx.net时候跳转到www.xx.com:
protected void Application_BeginRequest(Object sender, EventArgs e)
{
if (System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToLower().Equals("xx.net"))
{
string newurl = "http://www.xx.com" + System.Web.HttpContext.Current.Request.RawUrl;
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.StatusCode = 301;
System.Web.HttpContext.Current.Response.Status = "301 Moved Permanently";
System.Web.HttpContext.Current.Response.AddHeader("Location", newurl);
System.Web.HttpContext.Current.Response.End();
}
}