前提是在服务器供应商 ( 我的是阿里云 ) 将一级域名、二级域名都是用A解析解析在服务器上,可以ping通
首先打开 / xampp / apache / conf / httpd.conf
- // 将下面这行文本注释去掉 注释是用 # 来注释的
- Include conf/extra/httpd-vhosts.conf
然后打开 c / windows / system32 / drivers / etc / hosts 配置 host
- 127.0.0.1 xxx.com # 一级域名
- 127.0.0.1 a.xxx.com # 二级域名
最后一步就是配置二级域名指向路径
打开 / xampp / apache / conf / extra / httpd-vhosts.conf
- # 跟配置一级域名一样
- <VirtualHost *:80>
- ServerName xueshuai.top # 你的一级域名
- DocumentRoot "C:NewFilewebxueshuai.topdist" # 一级域名指向路径
- <Directory "C:NewFilewebxueshuai.topdist">
- Options FollowSymLinks IncludesNOEXEC Indexes
- DirectoryIndex index.html index.htm index.php
- AllowOverride all
- Order Deny,Allow
- Allow from all
- Require all granted
- </Directory>
- </VirtualHost>
-
- <VirtualHost *:80>
- ServerName a.xueshuai.top # 你的二级域名
- DocumentRoot "C:NewFileweba.xueshuai.topdist" # 二级域名指向路径
- <Directory "C:NewFileweba.xueshuai.topdist">
- Options FollowSymLinks IncludesNOEXEC Indexes
- DirectoryIndex index.html index.htm index.php
- AllowOverride all
- Order Deny,Allow
- Allow from all
- Require all granted
- </Directory>
- </VirtualHost>