咱们在本地开发时,通常是在浏览器输入 http://localhost/项目文件夹名 来测试网页文件,你有没有想过在本地在浏览器输入你本身设定的一个域名进入项目文件夹中去,本地配置多域名能够测试二级域名以及其余与域名相关的问题。apache
<VirtualHost *:80>windows
DocumentRoot "D:/wamp/www/test"浏览器
ServerName www.test.com测试
</VirtualHost>spa
<VirtualHost *:80>orm
DocumentRoot "D:/wamp/www/test/img"server
ServerName img.test.com开发
</VirtualHost>域名
<VirtualHost *:80>test
DocumentRoot "D:/wamp/www/"
ServerName localhost
</VirtualHost>
这个根据目录根据本身的apache文件目录来自行调整,个人apache工做目录为D:/wamp/www/,改为本身的apache工做目录便可。
最后一步,重启apache,在浏览器中输入:www.test.com会出现test文件夹的默认的内容
(在vhost里面加这个就开启了localhost)
<VirtualHost *:80>DocumentRoot "E:\wamp64\www"ServerName localhost </VirtualHost>