覆盖apache2虚拟主机configuration

我正在尝试为浏览我的网站的每个人显示403错误,除了我自己的IP。

这是一个临时修改,所以我不想改变我的每个虚拟主机。

我试过添加

<Directory /*> Deny from all </Directory> 

但是每个人都可以访问我的虚拟主机。 我能做什么 ?

对于这种情况,您可以将每个虚拟主机添加到共享资源中:

 Include conf/shared-virtualhosts.conf 

然后在这个文件中添加:

 <Location /> order deny,allow deny from all allow from ${yourallowedipaddress} </Location> 

当你完成后只是评论文件,并重新加载你的Apache。

使用.htaccess文件:

 order deny,allow deny from all allow from < your ip here > 

httpd.apache.org/docs/2.2/mod/mod_authz_host.html

确保.htaccessfunction已启用