在你想保护的ASP页面的顶部加上这些代码:
< %
if left(Request.ServerVariables("HTTP_REFERER"),24)
<> "http://www.yoursite.com/" and _
Request.ServerVariables("HTTP_REFERER") <> "" then
‘’We used Request.ServerVariables to get the domain name
‘’of the referring web page.
‘’If the domain name doesn‘’t equal my domain name, then
‘’I want to send the user to some other site
Response.Redirect "http://www.yahoo.com"
end if
% >
第二种办法是利用IP地址来判断用户访问的合法性,当你没有域名时,
用这种办法来进行在线测试是再方便不过的.
在你的ASP页面顶部加上这些代码:
< %
if Request.ServerVariables("REMOTE_HOST") <> "195.161.73.13" and _
Request.ServerVariables("REMOTE_HOST") <> "" then
‘’Send them away, if you like
Response.Redirect "http://www.yahoo.com"
end if
% >
文章来源于领测软件测试网 https://www.ltesting.net/