保護你的ASP頁面的兩種辦法 有時候你只想讓人們從你的站點來訪問你的某些頁面, 而不允許他們從其它站點的非法鏈接中到達這些頁面。 在你想保護的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 % >
|