vi /usr/local/apache2/conf/httpd.conf (去主配置文件拷贝)
拷贝如下信息:
AllowOverride None
Options None
Order allow,deny
Allow from all
vi /usr/local/apache2/conf/extra/httpd-vhosts.conf(将上面拷贝的信息粘贴进来,放到ErrorLog这行上面,并更改如下)
AllowOverride None
Options None
Order allow,deny
Allow from all
Deny from 127.0.0.1
保存退出
apachectl -t
apachectl restart
curl -x127.0.0.1:80 -I www.test.com
curl -x192.168.11.160:80 -I www.test.com/fourum.php
vi /usr/local/apache2/conf/extra/httpd-vhosts.conf(根据URI来控制,修改如下)
Order deny,allow
Deny from all
Allow from 127.0.0.1
Allow from 2.2.2.2
保存退出
apachectl -t
apachectl restart
curl -x192.168.11.160:80 -I www.test.com/admin.php
curl -x127.0.0.1:80 -I www.test.com/admin.php
拷贝如下信息:
AllowOverride None
Options None
Order allow,deny
Allow from all
vi /usr/local/apache2/conf/extra/httpd-vhosts.conf(将上面拷贝的信息粘贴进来,放到ErrorLog这行上面,并更改如下)
AllowOverride None
Options None
Order allow,deny
Allow from all
Deny from 127.0.0.1
保存退出
apachectl -t
apachectl restart
curl -x127.0.0.1:80 -I www.test.com
curl -x192.168.11.160:80 -I www.test.com/fourum.php
vi /usr/local/apache2/conf/extra/httpd-vhosts.conf(根据URI来控制,修改如下)
Order deny,allow
Deny from all
Allow from 127.0.0.1
Allow from 2.2.2.2
保存退出
apachectl -t
apachectl restart
curl -x192.168.11.160:80 -I www.test.com/admin.php
curl -x127.0.0.1:80 -I www.test.com/admin.php
编辑回复