[htaccess]虚拟主机屏蔽IP地址的方法

PHP通过 .htaccess文件屏蔽IP

代码如下

  1. RewriteEngine on
  2. RewriteBase /
  3. Order Deny,Allow ## 拒绝开关,allow表示拒绝访问
  4. Deny from 182.92.253.20 ##输入要屏蔽的IP地址
  5. Deny from 121.18.126 ## 屏蔽IP段

ASP

通过在首页添加以下代码实现

  1. <%
  2. requestIP = request.ServerVariables("REMOTE_ADDR")
  3. IP = "127.0.0.1|192.168.1.1"
  4. trueURL = "http://www.baidu.com"
  5. falseURL = "http://www.google.com"
  6. ipArr = split(IP,"|")
  7. flag = false
  8. for i=0 to ubound(ipArr)
  9. if requestIP=ipArr(i) then
  10. flag=true
  11. exit for
  12. end if
  13. next
  14. if flag then
  15. response.Redirect(falseURL)
  16. else
  17. response.Redirect(trueURL)
  18. end if
  19. %>

 

JS通过以下方式禁止IP访问

可以通过访问新浪提供借口获取IP地址归属地相关信息 :

http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=IP地址

 

1.JPG

原创文章,作者:大BOSS,如若转载,请注明出处:https://www.jiaseo.cn/913.html

(1)
上一篇 2018年12月24日 下午10:23
下一篇 2018年12月25日 下午11:37

相关推荐