asp中 Request.ServerVariables("HTTP_REFERER") 可以取得来源地址。
以下情况可以取得值:
1.直接用<a href>
2.用Submit或<input type=image>提交的表单(POST or GET)
3.使用Jscript提交的表单(POST or GET)
以下情况不能取得值:
1.从收藏夹链接
2.单击'主页'或者自定义的地址
3.利用Jscript的location.href or location.replace()
4.在浏览器直接输入地址
5.<%Response.Redirect%>
6.<%Response.AddHeader%>或<meta http-equiv=refresh>转向
7.用XML加载地址
由此可知, Request.ServerVariables("HTTP_REFERER")获取地址有局限性,不过通过这种局限性我们在后台中防止用户非常进入。
我们可以在后台认证的页面头部加入以下代码段:
ComeUrl=lcase(trim(request.ServerVariables("HTTP_REFERER")))
if ComeUrl="" then
response.write "对不起,为了系统安全,不允许直接输入地址访问本系统的后台管理页面。"
response.end
end if