- NameVirtualHost XXX.XXX.XXX.XXX
- <virtualhost XXX.XXX.XXX.XXX:80>
- ServerName XXX.XXX.XXX.XXX
- <Directory />
- Order Allow,Deny
- Deny from all
- </Directory>
- </virtualhost>
- <virtualhost XXX.XXX.XXX.XXX:80>
- ServerName yourdomain.com
- DocumentRoot /var/www/
- </virtualhost>
其中XXX.XXX.XXX.XXX为你的IP地址,第一处virtualhost配置为拒绝IP的任何访问请求,返回403错误。第二处的virtualhost配置为允许通过yourdomain.com这个域名访问,网站主目录为/var/www/(假设这是你的网站主目录)
转载于:https://www.cnblogs.com/qunshu/p/3537752.html