好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

如何设置Apache禁止使用IP直接访问

禁止IP直接访问网站有三种方法,一种是 设置 httpd.conf阻止连接,第二种是跳转到预设目录,还有一种就是 使用 .htacess来重写,三种方法选一即可。

下文假设禁止或IP地址为12.34.56.78,端口为80。

一、设置httpd.conf配置阻止

添加配置内容如下:

NameVirtualHost 12.34.56.78:80 <VirtualHost 12.34.56.78:80> ServerName 12.34.56.78 <Location /> Order Allow,Deny Deny from all </Location> </VirtualHost>

二、设置IP访问跳转

配置内容如下:

NameVirtualHost 12.34.56.78:80 <VirtualHost 12.34.56.78:80> ServerName 12.34.56.78 DocumentRoot "/srv/www/default" </VirtualHost>

三、设置.htaccess

屏蔽IP也可以设置在.htaccess里,只需在.htaccess中增加:

Order Deny,Allow Deny from 12.34.56.78

查看更多关于如何设置Apache禁止使用IP直接访问的详细内容...

  阅读:154次