如发现博文存在问题,可以随时滴滴我

xampp配置虚拟域名

首先使用notpad++(我用的notpad++,记事本也可以)打开(安装xampp目录下的)apach——>conf——>extra——>httpd-vhosts.conf

在文件的最下面添加如下代码

<VirtualHost *:80>
	ServerName xueshuai.com    //访问的域名
	DocumentRoot "E:\WEB-XueShuai\example\**********"    //指向的地址
	<Directory "E:\WEB-XueShuai\example\**********">     //指向的地址
		Options FollowSymLinks IncludesNOEXEC Indexes
		DirectoryIndex index.html index.htm index.php
		AllowOverride all 
		Order Deny,Allow 
		Allow from all 
		Require all granted
	</Directory>
</VirtualHost>

然后使用notpad++(我用的notpad++,记事本也可以)打开C盘——>windows——>system32——>drivers——>etc——>hosts

在文件的最后添加如下代码

127.0.0.1 xueshuai.com     //后面是你的虚拟域名

如果没有hosts这个文件,复制该文件夹下面的任意文件,将其重命名为hosts,并将里面内容删掉改为如下:

# 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
127.0.0.1 localhost

接下来重启xampp的apach和mysql

在浏览器中输入你所设置的虚拟域名(xueshuai.com)即可跳转到所指定的位置

此处有个坑---当把hosts文件下的虚拟域名配置httpd-vhosts.conf里的配置给删掉之后,在浏览器中输入虚拟域名还是会跳转,这是因为浏览器的缓存机制,清除缓存即可

posted @ 2019-07-23 22:33  webxue  阅读(378)  评论(0编辑  收藏  举报