全站301与首页301重定向的区别在之前的建站教程中,我们介绍过如何给网站做301重定向,这是一种网站首页重定向的方法,只能将网站首页重定向到另一个地址,而其它的内页是无法转向的。 而全站301重定向是将网站的所有页面都一次性重定向到另一个地址,保证了网站中已被收录的网页的权重的转移,做了全部301重定向后,老网站所有页面的http返回码都为301. 全站301重定向方法不同的建站程序语言实现全站301重定向的方法是不一样的. ASP程序网站全站301重定向: Dim url Dim Num If request.ServerVariables("HTTP_HOST")<>"www.abc.com" Then If Request.ServerVariables("Script_Name")<>"" Then Num=Len(Request.ServerVariables("Script_Name"))-11 If right(Request.ServerVariables("Script_Name"),11)<>"default.asp" Then url = "http://www.abc.com"&Request.ServerVariables("Script_Name")&"?"&Request.ServerVariables("Query_String") Else url = "http://www.abc.com"&left(Request.ServerVariables("Script_Name"),Num) End If Response.Status="301 Moved Permanently" Response.AddHeader "Location",url Response.End Else Response.Status="301 Moved Permanently" Response.AddHeader "Location","http://www.xuewangzhan.net/" Response.End End If End If |