第一步:配置 httpd.conf
路径 :C:xamppapacheconf
开启 虚拟主机 配置模块 去掉 " Include conf/extra/httpd-vhosts.conf " 前面的" # "
# Virtual hosts Includeconf/extra/httpd-vhosts.conf
第二步:配置 httpd-vhosts.conf
路径 :C:xamppapacheconfextra
开始 将自定义的本地域名 与 web目录 关联 这里自定义了
www.royal.org
www.superapp.com
www.api.com
这三个本地域名 (当然这三个域名 是不能远程访问的 什么原因 你懂的!)
NameVirtualHost *:80 <VirtualHost *:80> ServerName * DocumentRoot D:webapache2.2Apache2htdocs </VirtualHost> <VirtualHost *:80> ServerName www.royal.org DocumentRoot "D:webapache2.2Apache2htdocsRoyal" <Directory "D:webapache2.2Apache2htdocsRoyal"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost> <VirtualHost *:80> ServerName www.superapp.com DocumentRoot "D:webapache2.2Apache2htdocsscApp7" <Directory "D:webapache2.2Apache2htdocsscApp7"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost> <VirtualHost *:80> ServerName www.api.com DocumentRoot "D:webapache2.2Apache2htdocs aobaoApi" <Directory "D:webapache2.2Apache2htdocs aobaoApi"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost>
第三步: 配置windows hosts文件
打开 C:WINDOWSsystem32driversetchosts 文件
(hosts文件其实 就是 internet 的雏形 最早的internet 是 ARPA 用于内部的 主机的域名解析)
1
2
3
|
127.0.0.1 www.royal.org
127.0.0.1 www.superapp.com
127.0.0.1 www.api.com
|
第四步:没哟了! 在浏览器上 输入 www.api.com www.superapp.com www.royal.com 就会访问不同的本地web目录
转自:https://my.oschina.net/justphp/blog/124422