wamp下配置多域名和访问路径的方法
1.到安装目录下,打开配置httpd.conf
D:\wamp\bin\apache\Apache2.2.21\conf\httpd.conf
也可以通过wamp图标打开。查找 Virtual hosts 去掉下面include行前面的# 修改为
#Virtual hosts
Include conf/extra/httpd-vhosts.conf
这样就在配置文件中引入了httpd-vhosts.conf文件。
2.配置域名
D:\wamp\bin\apache\Apache2.2.21\conf\extra\httpd-vhosts.conf
添加类型如下域名和指向路径:
<VirtualHost *:80>
ServerAdmin zhengdunzhuang@wnw3d.com
DocumentRoot "D:/wamp/www/testphp"
ServerName www.testphp.com
ErrorLog "logs/www.testphp.com-error.log"
CustomLog "logs/www.testphp.com-access.log" common
</VirtualHost>
3.配置别名
到对应目录下,如D:\wamp\alias,创建访问目录别名文件,如:testphp.conf
添加如下内容:
Alias /testphp "d:/wamp/www/testphp/"
<Directory "d:/wamp/www/testphp/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
4.配置window的hosts
打开C:\Windows\System32\drivers\etc\hosts文件,添加对应域名,如:
127.0.0.1 localhost
127.0.0.1 www.testphp.com
5.重启wamp服务让配置生效,然后在浏览器输入测试地址:
http://www.testphp.com/
http://localhost/testphp/
如果都能正常访问说明配置成功