首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

301重定向的有关问题

2012-06-21 
301重定向的问题string server System.Web.HttpContext.Current.Request.ServerVariables[SERVER_NAME

301重定向的问题
string server = System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToLower();

  if (server.Equals("http://aaa.com/") && System.Web.HttpContext.Current.Request.Url.ToString().ToLower().Replace(server, "").Length > 0)
  {
  string newurl = "http://www.aaa.com/";
  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);
  }

在首页Page_load里添加这个,但是全是跳到http://aaa.com/www.aaa.com
为什么呢???

[解决办法]
你确定 newurl 的赋值是 "http://www.aaa.com/" 而不是 "www.aaa.com/" 吗?
[解决办法]
坐观 高手解决

热点排行