需要添加虚拟主机,配置文件应该是 apache目录/conf/extra/httpd-vhosts.conf,这个文件中有示例,照着配一下即可,以下为一个简单的例子,有以下几项的简单配置就可以运行了,如果需要别名、rewrite都可以加在里边,<VirtualHost *:80> ServerAdmin admin@abc.com DocumentRoot “/home/xyz/htdocs” ServerName xyz.abc.com <Directory “/home/xyz/htdocs”> Options Indexes FollowSymLinks AllowOverride None order allow,deny Allow from all </Directory></VirtualHost>然后在httpd.conf中把这个文件载入:Include conf/extra/httpd-vhosts.conf
ServerName 192.168.1.1
Order Allow,Deny
Deny from all
DocumentRoot “D:\web\”
ServerName http://www.baidu.com
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
前面加个IP拒绝访问,就只允许用域名访问。
ServerName 192.168.1.1
Order Allow,Deny
Deny from all
DocumentRoot “D:\web\”
ServerName http://www.baidu.com
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
前面加个IP拒绝访问,就只允许用域名访问。
若访问出现403错误,
添加红色部分即可。
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot “D:/www”
ServerName www.abc.com
ErrorLog “logs/dummy-host2.example.com-error.log”
CustomLog “D:/wamp/logs/access.log” common<Directory “D:/www”>Options FollowSymLinksAllowOverride NoneOrder deny,allowRequire all granted</Directory>
</VirtualHost>