保护你的ASP页面的两种办法

时间:2008-06-10 16:53:00 

保护你的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 
% > 

 

标签:盗链,IP,asp
0
投稿

猜你喜欢

  • python实现将pvr格式转换成pvr.ccz的方法

    2022-09-01 05:54:14
  • JavaScript DOM节点操作方法总结

    2024-04-16 09:24:36
  • 理解SQL SERVER中的逻辑读,预读和物理读

    2012-01-05 19:32:29
  • 实践Python的爬虫框架Scrapy来抓取豆瓣电影TOP250

    2021-04-26 21:27:11
  • Python安装及Pycharm安装使用教程图解

    2023-08-01 05:38:06
  • Python及Django框架生成二维码的方法分析

    2023-10-11 22:25:48
  • 将Django框架和遗留的Web应用集成的方法

    2023-04-11 11:18:52
  • pyqt5简介及安装方法介绍

    2022-05-21 15:18:53
  • 在Debian下配置Python+Django+Nginx+uWSGI+MySQL的教程

    2023-04-22 23:03:44
  • python 经典数字滤波实例

    2022-08-26 10:23:22
  • python 利用jieba.analyse进行 关键词提取

    2021-03-16 22:11:26
  • python接口测试返回数据为字典取值方式

    2021-09-27 07:37:00
  • MySQL 逻辑备份与恢复测试的相关总结

    2024-01-19 14:19:20
  • 对Python中plt的画图函数详解

    2023-08-16 08:49:07
  • Python MySQLdb模块连接操作mysql数据库实例

    2024-01-18 03:10:26
  • python之线程池map()方法传递多参数list

    2022-06-13 09:00:55
  • python中from module import * 的一个坑

    2021-10-29 08:23:51
  • CSS模块化设计—从空格谈起

    2007-12-15 09:41:00
  • Python字符串拼接的几种方法整理

    2021-05-08 18:55:47
  • mysql 存储过程中变量的定义与赋值操作

    2024-01-22 18:44:55
  • asp之家 网络编程 m.aspxhome.com