服务器 频道

apache 如何设置禁止IP直接访问

  【IT168 服务器学院】apache虚拟主机默认情况下ip地址方式访问(http://xxx.xxx.xxx.xxx) 对应第一个虚拟主机,所以我们可以先建一个指向错误页面的虚拟主机,达到禁止用ip访问网页的目的。

  方法一:建一个虚拟主机,

  ServerName IPAddress (比如192.168.0.1)

  DocumentRoot /usr/local/apache/nosite/

  这样就可以了。

  在/usr/local/apache/nosite/下面建一个index.htm,提示用户,不允许IP访问。或其它出错信息。

  方法二:

  ServerName IPAddress (比如192.168.0.1)

  DocumentRoot /usr/local/apache/nosite/

  Order deny,allow

  Deny from all

  参考:http://bbs.chinaunix.net/viewthread.php?tid=662222

  http://w.yi.org/ftp/FAPM/apache/Apache2/zh/howto/auth.html

0
相关文章