PHP本地通过映射,实现多域名访问
PHP本地通过映射,实现多域名访问
第一步:先在C盘下的windows/system32/drivers/etc/hosts文件加上
127.0.0.1 localhost
127.0.0.1 test
127.0.0.1 www.weishang.com
第二步:在Apache的服务器下的conf/extra/httpd-vhosts.conf
加上以上代码:
<VirtualHost *:80>
ServerAdmin postmaster@dummy-host.localhost
DocumentRoot "E:/wamp/www/"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/dummy-host.localhost-error.log"
CustomLog "logs/dummy-host.localhost-access.log" combined
</VirtualHost> ## localhost 的配置也要有,别忘了写 ##
<VirtualHost *:80>
ServerAdmin postmaster@dummy-host.test
DocumentRoot "E:/wamp/www/weishang/mobile/"
ServerName test
ServerAlias test
ErrorLog "logs/dummy-host.test-error.log"
CustomLog "logs/dummy-host.test-access.log" combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin postmaster@dummy-host.www.weishang.com
DocumentRoot "E:/wamp/www/weishang/mobile/"
ServerName www.weishang.com
ServerAlias www.weishang.com
ErrorLog "logs/dummy-host.www.weishang.com-error.log"
CustomLog "logs/dummy-host.www.weishang.com-access.log" combined
</VirtualHost>
第三步:在apache/conf/httpd.conf文件里找到
Include conf/extra/httpd-vhosts.conf 并开启
然后重新启动Apache服务器
参考:http://jingyan.baidu.com/article/154b46315e76af28ca8f4135.html
http://hi.baidu.com/baiping588