1.找到wampserver安装文件夹\wamp\bin\apache\Apache2.2.21\conf\extra\httpd-vhosts.conf
然后可以看到
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com //管理员邮箱地址
DocumentRoot "c:/Apache2/docs/dummy-host2.example.com" //文件的目录,即网站代码所在目录
ServerName dummy-host2.example.com //主机名
ErrorLog "logs/dummy-host2.example.com-error.log"//错误日志
CustomLog "logs/dummy-host2.example.com-access.log" common//日常日志
</VirtualHost>
但是下面这三行暂时用不到,可以先不用管它
ServerAdmin webmaster@dummy-host2.example.com //管理员邮箱地址ErrorLog "logs/dummy-host2.example.com-error.log" //错误日志
CustomLog "logs/dummy-host2.example.com-access.log" common //日常日志
现在我只要修改下面这两行
DocumentRoot "D:/demo/future" //文件的目录,即网站代码所在目录
ServerName www.future.com //主机名
配置好后还不够哦,还得进行下面几步
2.选中
然后ctrl+f打开查找框输入httpd-vhosts,然后把前面的#去掉
接着保存
接下再次打开httpd.conf文件
Ctrl+f查找代码放在的目录,然后改成图片中的样子
然后重启服务
3.记着在代码文件下创建相应的代码文件哦
4.最后一步修改C:\Windows\System32\drivers\etc中host文件如下
最后在浏览器上输入www.future.com就可以了,哈哈,简单吧