Apache 配置虚拟域名的最简单方式

一、配置httpd.conf:

1、取消Include conf/extra/httpd-vhosts.conf的注释,代码如下:

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

2、虚拟域名关联项目根目录(入口文件index.php的根目录),代码如下:

<VirtualHost *:80>
ServerName www.fuckoff.com
DocumentRoot "D:/Apache2.2/htdocs/web"
</VirtualHost>

二、配置hosts文件(C:WindowsSystem32driversetc):

1、在hosts文件中写上需要配置的虚拟域名,例如

127.0.0.1       www.fuckoff.com

注意:每次修改Apache配置都需要重启Apache

原文地址:https://www.cnblogs.com/jamespan23/p/5768202.html