只要不是HTTP_REFERER來源於(google.com google.cn *.google.com *.google.cn baidu.com *.baidu.com)這些網址來源的請求,就通通轉發至404
復制代碼 代碼如下:
<%
Dim a, reg
a = Request.ServerVariables("HTTP_REFERER").Item
Set reg = New RegExp
reg.Pattern = "^http://(?:[^.]*\.)?(?:google\.com|google\.cn|baidu\.com)(/|$)"
reg.IgnoreCase = True
If Not reg.Test(a) Then
Set reg = Nothing
Response.Status = "404 File Not Found."
Response.End
End If
Set reg = Nothing
' .... 繼續
%>
復制代碼 代碼如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%Dim OK_URL,URL,HTTP_REFERER
'自定義需要過濾的字串,用 "|" 分隔
OK_URL= "google.com|google.cn|baidu.com"'排除信息
OK_URL= split(OK_URL,"|") '分割排除信息
URL="404.htm" '設定指向頁面
HTTP_REFERER=Request.ServerVariables("HTTP_REFERER")'獲取來源網址
If HTTP_REFERER<>"" Then
For Each REFERER In HTTP_REFERER
For i=0 To Ubound(OK_URL)
If Instr(LCase(HTTP_REFERER(REFERER)),OK_URL(i))=0 Then'如果來源網址不是以上排除項的話,那就直接返回所指向的網頁!
Response.Redirect(URL):Response.End()
End if
Next
Next
End If%>