野狼SEO团队,纯白帽SEO倡导者!16年专注网站优化服务,支持月付!  [点击查看公司宣传册]
专注纯白帽、整站正规优化
让你排名上升,流量暴涨!
网站优化服务电话
0371-56789-390
详细内容
当前位置:首页 > 技术资料 > ASP程序开发 > 详情

301永久重定向的asp程序源码

发布时间:2017-02-13 来源:本站原创 作者:野狼SEO团队 阅读:834

301永久重定向也可以使用asp程序来做,这跟用php做301重定向的代码逻辑相同,只是代码略微有区别而已:

Response.Status="301 Moved Permanently"

Response.AddHeader "Location", "http://www.390seo.com"

第一行是说明跳转是301的状态,第二行是让进行跳转。

下边是野狼经常用的301跳转代码完整版:

<%

Dim domain301,sn
domain301=Request.ServerVariables("Server_name") // 获取域名
//这里的3是指www的长度
if left(domain301,3)<>"www" then
Response.Status="301 Moved Permanently"
if(Request.ServerVariables("Query_String") <> "" ) then
Response.AddHeader "Location", "http://www.390seo.com"&Request.ServerVariables("Path_Info") &"?"&Request.ServerVariables("Query_String")
elseif(Request.ServerVariables("Path_Info") = "/index.asp" ) then
Response.AddHeader "Location", "http://www.390seo.com"
else
Response.AddHeader "Location", "http://www.390seo.com"&Request.ServerVariables("Path_Info")
end if
Response.End
end if

%>

注意事项:

1、如果是伪静态的网站,跳转就会跳到动态网址,我们建议这种情况不要用程序跳转,而是用伪静态做301跳转或者设置服务器来做。
2、注意首页的默认后缀跳转的时候可能会带上“index.php”或者“default.php”等。


附件:

php和asp版本的301永久重定向源码下载  


本文作者:野狼SEO团队

十六年网站建设相关经验
一站式为您提供网站相关服务

欢迎扫码咨询

访客头像访 客3.233***
新评论

还没有人评论,快来抢个沙发!