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里的配置给删掉之后,在浏览器中输入虚拟域名还是会跳转,这是因为浏览器的缓存机制,清除缓存即可

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

前端薛小帅

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值