、打开系统盘,默认是C:\Windows\System32\drivers\etc,如果系统盘是D盘就打开D:\Windows\System32\drivers\etc:

、用记事本打开hosts:

、打开之后默认如下,不太一样也不要在意。因为这个有可能不相同的。

、 127.0.0.1为本地ip 可以为其他ip设置名称,本地也可以添加多个

# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
127.0.0.1       localhost
127.0.0.1       www.test.com
127.0.0.1       www.fh.com
127.0.0.1       www.test_my.com

 
设置之后需要到apache配置文件中配置文件
1、

首先修改C:\Windows\System32\drivers\etc目录下的 hosts 文件,用记事本打开,加入:

# Copyright (c) 1993-2009 Microsoft Corp.
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
127.0.0.1       localhost
127.0.0.1       www.test.com
127.0.0.1       www.fh.com
127.0.0.1       www.test_my.com

//127.0.0.1 www.a.com127.0.0.1 www.b.com记得去掉前面的

 
2、

打开xampp\apache\conf\httpd.conf文件,搜索 “Include conf/extra/httpd-vhosts.conf”,确保前面没有 # 注释符,也就是确保引入了 vhosts 虚拟主机配置文件。效果如下:

# Virtual hosts

Include "conf/extra/httpd-vhosts.conf"

开启了httpd-vhosts.conf,默认a的httpd.conf默认配置失效(确保 httpd-vhosts.conf 文件里也开启了虚拟主机配置,见第3条),访问此IP的域名将全部指向 vhosts.conf 中的第一个虚拟主机。

3、

在虚拟主机设置文件xampp\apache\conf\extra \httpd-vhosts.conf里设置:取消 NameVirtualHost *:80 前面的 ##,这样就启用了 vhosts.conf ,默认的httpd.conf默认配置失效。虚拟主机配置将只设置在httpd-vhosts.conf里。localhost 的目录默认配置记得也按此设置。

<VirtualHost *:80>
    ServerAdmin fh@fh.com
    DocumentRoot "D:/feihu/xampp/htdocs/mylaravel/public"
    ServerName www.fh.com
    ErrorLog "logs/fh.com-error.log"
    CustomLog "logs/fh.com-access.log" common
</VirtualHost>

#

# Use name-based virtual hosting.

#

NameVirtualHost *:80

#

# VirtualHost example:

# Almost any Apache directive may go into a VirtualHost container.

# The first VirtualHost section is used for all requests that do not

# match a ServerName or ServerAlias in any block.

#

ServerAdmin postmaster@dummy-host.localhost

DocumentRoot "I:/xampp/htdocs/"

ServerName localhost

ServerAlias localhost

ErrorLog "logs/dummy-host.localhost-error.log"

CustomLog "logs/dummy-host.localhost-access.log" combined

ServerAdmin postmaster@dummy-host1.localhost

DocumentRoot "I:/xampp/htdocs/a"

ServerName www.a.com

ServerAlias www.a.com

ErrorLog "logs/dummy-host1.localhost-error.log"

CustomLog "logs/dummy-host1.localhost-access.log" combined

ServerAdmin postmaster@dummy-host2.localhost

DocumentRoot "I:/xampp/htdocs/b/"

ServerName www.b.com

ServerAlias www.b.com

ErrorLog "logs/dummy-host2.localhost-error.log"

CustomLog "logs/dummy-host2.localhost-access.log" combined

//至此,XAMPP 的虚拟主机设置完毕,现在 访问 localhost 还是原来的 XAMPP 的帮助指南,访问 www.a.com 将指向到绑定的 a 目录,访问 www.b.com 将指向到绑定的 b 目录。

 
 访问www.fh.com将访问刚才设置的自定义文件夹

最新文章

  1. 你该知道的-SQL里的这些新语法-函数
  2. ng1.3+表单验证&lt;AngularJs&gt;
  3. 如何使用XShell登录亚马逊EC2云服务器
  4. OD使用教程
  5. eclipse无法识别javax.servlet.*的问题
  6. jQuery入门第三天
  7. 手拼Table 前台显示
  8. 每天学点GDB 12
  9. ZOJ 1243 URLs
  10. Make Things Move -- Javascript html5版(三)三角函数形式的动画
  11. DOM:文档对象模型 --树模型
  12. 编译安装LAMP并实现wordpress
  13. LINUX 笔记-文件属性相关命令
  14. 【一天一道LeetCode】#242. Valid Anagram
  15. 2018-2019-2 20165336《网络对抗技术》Exp0 Kali安装 Week1
  16. 2018.2.22 学习笔记 random模块及每日一练
  17. 用python计算圆周率Π
  18. oracle 数据库去重复数据
  19. CSS——对position定位和margin-top的理解
  20. Math对象属性

热门文章

  1. Struts2的通配符配置方式
  2. 【for陷阱】遍历的同时删除元素
  3. python 内嵌函数, 闭包, 函数装饰器
  4. oracle数据库 参数open_cursors和session_cached_cursor详解!
  5. iOS 打包上传AppStore相关(3)-iTunes相应配置以及使用蒲公英网站进行应用托管分发(链接/二维码)
  6. python 基础学习4-with语句
  7. 部分服务器使用phpExcel会报错
  8. 湖南多校对抗赛(2015.05.03)Problem B: War
  9. R绘图学习笔记
  10. 数据库DateTime类型为空的处理