打印本文 打印本文 关闭窗口 关闭窗口
asp利用404实现.html虚拟静态页面和图片防盗链技术
作者:武汉SEO闵涛  文章来源:本站原创  点击数1073  更新时间:2010/7/16 9:06:30  文章录入:mintao  责任编辑:mintao

很将一下代码保存为"404.asp“

<%
Response.expires = 0
Response.expiresabsolute = Now() - 1
Response.addHeader "pragma", "no-cache"
Response.addHeader "cache-control", "private"
Response.CacheControl = "no-cache"

CurrDomain=Request.ServerVariables("HTTP_HOST") '当前访问域名
CurrURL=Replace(Request.ServerVariables("QUERY_STRING"),"404;http://"&CurrDomain&":80/","")
Ourl=CurrURL
'Ourl="Names---Goods_List__ID-20_Sort-100.htm"
if instr(ourl,".jpg") then
if instr(Request.ServerVariables("HTTP_REFERER"),"127.0.0.1")>0 then
response.Redirect("http://"&CurrDomain&"/"&replace(ourl,"-ndfpic-",""))
else

end if
response.End()
end if

if instr(ourl,"---") then
ourl=replace(ourl,left(ourl,instr(ourl,"---")+2),"")
end if

if instr(ourl,".html") then
  if instr(ourl,"__")>0 then Fname=left(ourl,instr(ourl,"__")-1)

    if Fname="" then '如果只有.html直接转向
     'response.Redirect(replace(ourl,".html",".asp"))
  'response.Write(replace(ourl,".html",".asp"))
     reu replace(ourl,".html",".asp")
     response.End()
     'Fname=left(ourl,instr(ourl,".")-1)
    end if

url1=replace(ourl,left(ourl,instr(ourl,"__")+1),"")
url1=replace(url1,".html","")
Str=split(url1,"_")
for N=0 to UBound(Str)
   if N=0 then
   Values=replace(Str(N),"-","=")
   else
   Values=Values&"&"&replace(Str(N),"-","=")
   end if
next
URL=Fname&".asp?"&Values
ReU URL
response.End()
else
response.Write("The file does not exist!"&"<br>"&Ourl)
end if

Function ReU(Str)
response.Write(GetU("http://"&CurrDomain&"/"&Str))
'response.Write("http://"&CurrDomain&"/"&Str)
end function

Function GetU(url) 
 'On Error Resume Next
 dim http
 set http=Server.createobject("Microsoft.XMLHTTP") 
 Http.open "GET",url,false
 Http.setRequestHeader "Referer:http://","Host:60.60.60.60"
 Http.send() 
 if Http.readystate<>4 then
  exit function 
 end if

 GetU=bytesTobSTR(Http.responseBody,"gb2312")
 set http=nothing
 If Err.number<>0 then 
  GetU="Error"
  Err.Clear
  exit function 
 End If  
End function

Function BytesToBstr(body,Cset)
 dim objstream
 set objstream = Server.CreateObject("adodb.stream")
 objstream.Type = 1
 objstream.Mode =3
 objstream.Open
 objstream.Write body
 objstream.Position = 0
 objstream.Type = 2
 objstream.Charset = Cset
 BytesToBstr = objstream.ReadText 
 objstream.Close
 set objstream = nothing
End Function
%>

打印本文 打印本文 关闭窗口 关闭窗口