<VirtualHost *:80>
ServerName IP
ServerAlias IP
<Location />
Order Allow,Deny
Deny from all
</Location>
</VirtualHost>

上述代码添加到httpd.conf后重启apache即可禁止IP直接访问网站。

Related Posts: Apache禁止通过IP直接访问 :