Request.ServerVariables(”HTTP_REFERER”)的工作方式
下列情況是從瀏覽器的地址欄正常取得Request.ServerVariables(”HTTP_REFERER”)的:
1.直接用<a href>
2.用Submit或<input type=image>提交的表單(POST or GET)
3.使用Jscript提交的表單(POST or GET)
Request.ServerVariables(”HTTP_REFERER”)不能正常取值的情況:
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”)在多數情況下是不能正常工作的,正因為這個原因,在防止下載盜鏈時我們才能使Request.ServerVariables(”HTTP_REFERER”)。
如一例:
以下是代碼片段: '下載系統網址列表,不要帶上http:// domain=”Vevb.com,61.156.14.223″ splDomain=split(domain,”,”) strReferer=Request.ServerVariables(”HTTP_REFERER”) for iii = 0 to ubound(splDomain) if instr(strReferer,trim(splDomain(iii)))>0 then isHttp=True next if isnull(strReferer) or isHttp=false then Response.Write “下載鏈接來自非法盜鏈,<a href=”http://www.Vevb.com/“>請進入武林網頁面後再進行下載。</a>” CloseDatabase response.end end if |