正在加载中...
使用asp代码实现301跳转和网站旧链接回收的代码示例
如果你的网站改版,有一个旧链接已被百度收录,但新版页面不想直接覆盖,防止被降权,那么就可以将旧链接301跳转到新的链接,以便传导权重。下面给一段asp变成实现301永久重定向的代码示例,希望对朋友们有用!
Dim Server_Name,Path_infostr,Query_Stringstr Path_infostr=lcase(request.ServerVariables("PATH_INFO")) Server_Name=lcase(request.ServerVariables("Server_Name")) Query_Stringstr=request.ServerVariables("Query_String") If Query_Stringstr<>"" Then Query_Stringstr="?"&Query_Stringstr IF instr(Server_Name,"www.")<1 Then Response.Status = "301 Moved Permanently" if instr(Path_infostr,"index")>0 or instr(Path_infostr,"default")>0 Then Response.AddHeader "Location","http://www."&Server_Name Else Response.AddHeader "Location","http://www."&Server_Name&Path_infostr&Query_Stringstr End if Response.End End if
万维景盛提供网站改版、服务器代维、阿里云服务器折上折代购、SSL证书采购、安全防护、建站仿站等服务,欢迎垂询!