1.打开C:/WINDOWS/system32/drivers/etc,看下面有没有hosts文件,若存在在此文件尾加入两行:
若不存在复制以下内容到记事本,将名字改为hosts,去掉txt后缀名。
# Copyright (c) 1993-1999 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
#
# 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
127.0.0.1 localhost
127.0.0.1
www.myweb1.com
127.0.0.1 www.myweb2.com
2.打开xampp安装目录:D:/xampp/apache /conf,找到文件httpd.conf,打开并查找“Virtual hosts” 确保下面一行没有##号,修改后保存.
127.0.0.1 www.myweb2.com
2.打开xampp安装目录:D:/xampp/apache /conf,找到文件httpd.conf,打开并查找“Virtual hosts” 确保下面一行没有##号,修改后保存.
3.打开D:/xampp/apache/conf/extra,找到文件httpd-vhosts.conf,打开并查找 “NameVirtualHost”确保该行前面没有#号,再在末尾加入以下几行:
<VirtualHost *:80>
DocumentRoot /xampp/htdocs/
ServerName localhost
</VirtualHost>
DocumentRoot /xampp/htdocs/
ServerName localhost
</VirtualHost>
修改后保存。
4.重启Apache,在地址栏输入域名
www.myweb1.com 回车即可打开原来要输入路径才能打开的网页。