为了实现像百度那样可以用www.baidu.com访问页面也不是用IP地址访问,在Apache上需要配置如下信息:
1.在httpd.conf文件中开启虚拟主机功能:
2.在conf/extra目录下的httpd-vhosts.conf文件中加入如下代码:
#配置自定义虚拟主机
<VirtualHost 127.0.0.1:80>
DocumentRoot "D:/XAMPP/httpd-2.4.16-win64-VC14/MyServer"
DirectoryIndex index.html intex.htm index.php
<Directory />
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
3.C:\Windows\System32\drivers\etc目录下修改host文件,加入IP地址与域名的映射即可
#在win10系统中是不能修改这个文件的,所以要在属性中更改一下文件访问权限即可