In fact, my original intention of doing this is to prevent hot links! Please help me find out how to eradicate hotlinking through code! As long as HTTP_REFERER does not come from (google.com google.cn *.google.com *.google.cn baidu.com *.baidu.com) requests from these URL sources will be forwarded to 404
Copy the code code as follows:
<%
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
Setreg=Nothing
Response.Status = 404 File Not Found.
Response.End
End If
Setreg=Nothing
' .... continue
%>
Copy the code code as follows:
<%@LANGUAGE=VBSCRIPT CODEPAGE=65001%>
<%Dim OK_URL,URL,HTTP_REFERER
'Customize the strings that need to be filtered, separated by |
OK_URL= google.com|google.cn|baidu.com' exclusion information
OK_URL= split(OK_URL,|) 'Split exclusion information
URL=404.htm 'Set the page to point to
HTTP_REFERER=Request.ServerVariables(HTTP_REFERER)'Get the source URL
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'If the source URL is not one of the above exclusions, then return directly to the webpage pointed to!
Response.Redirect(URL):Response.End()
End if
Next
Next
End If%>