A section of ASP Http_referer judgment code _ Application Skills

Source: Internet
Author: User
As long as it is not http_referer from (google.com google.cn *.google.com *.google.cn baidu.com *.baidu.com) requests from these web site sources, they are forwarded to 404
Copy 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
Set reg = Nothing
Response.Status = "404 File not Found."
Response.End
End If
Set reg = Nothing



' .... Go on
%>


Copy Code code as follows:

<% @LANGUAGE = "VBSCRIPT" codepage= "65001"%>
<%dim Ok_url,url, Http_referer
' Customize the string to be filtered, with ' | ' delimited

ok_url= ' google.com|google.cn|baidu.com ' Exclude information
Ok_url= split (Ok_u RL, "|") ' Split exclusion information
Url= "404.htm" ' Set point to Page
Http_referer=request.servervariables ("http_referer") ' Get Source URL
If http_refere R<> "" Then
for each REFERER in Http_referer
for i=0 to Ubound (ok_url)
If Instr (LCase ( REFERER)), Ok_url (i)) =0 Then ' If the source URL is not the above exclusions, then return directly to the page you are pointing to!
Response.Redirect (URL): Response.End ()
End If

Next
Next
End if%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.