控制面板 - 帮助中心 - 付款方式 - 常用文档 - 软件下载 -   
服务中心
当前位置:首页 - 服务中心 - 网络学院

asp判断网站301重定向

  301重定向一般用于网站改版,或者转发中。301转发对于搜索引擎来讲是一种最有益的转发。对于自己的网站我们可以很清楚是用的URL转发功能还是301功能,但对于别人的网站我们很难直接分辨出来。下面我们来看一下如何用ASP脚本语言来判断301转发的状态。

  代码如下:

<%
response.expires=0
response.addHeader "pragma","no-cache"
response.addHeader "Cache-Control","no-cache, must-revalidate"
url=lcase(request.QueryString("url"))
%>
<html><head></head><body><form method="get">
<input type="text" name="url" value="<%=url%>" size="40"/><input type="submit" value="查询状态" />
</form>
<%
call  gethttpstat(url)
function gethttpstat(urlstr)
 on error resume next
 dim xmlhttp,webState,url2
 if urlstr="" then exit function
 if left(urlstr,5)<>"http:" then urlstr="http://" & urlstr
 if instr(8,urlstr,"/")=0 then urlstr=urlstr & "/"
 set xmlhttp=server.CreateObject("WinHttp.WinHttpRequest.5.1")
 xmlhttp.SetTimeouts 10000,10000,10000,10000
 xmlhttp.Option(6)=0
 xmlhttp.open "GET",urlstr,False
 xmlhttp.send
 
 webState=xmlhttp.Status
 if err.number<>0 then webState=err.Description
 result= "<font color=red>" & urlstr & "</font>  -->  <font color=blue>" & webState & "</font><br>"
 response.Write result
 if webState="301" or webState="302" then
  xxx=xmlhttp.getResponseHeader("Location")
  call gethttpstat(xxx)
    end if
 set xmlhttp=nothing
end function
%>
</body></html>

  上传至服务器运行即可实现在线检测。

更新时间:2010-6-13

7*24小时咨询热线:400-628-6536 0371-86013552 19937165195
传真:0371-86013552-6612 服务邮箱:web@3a88.com 代理邮箱:agent@3a88.com 备案邮箱:beian@3a88.com
运营商:郑州金飞科技有限公司 工商营业执照号:9141010567945717XL
公司地址:郑州高新技术产业开发区木兰里9号1号楼1单元14层310号 邮政编码:450000 豫ICP备12025635号-1 豫公网安备 41010502003077号