- 打开 apache 的 rewrite 模块:在
httpd.conf
配置文件中找到LoadModule rewrite_module modules/mod_rewrite.so
,去掉它前面的#
。 - 编辑文件:
C:\Windows\System32\drivers\etc\hosts
,新增一行:
127.0.0.1 www.xiaoyu.com
。 - 编辑文件:
\xampp\apache\conf\extra\httpd-vhosts.conf
,新增一段:
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "e:\xampp\htdocs"
ServerName www.xiaoyu.com
ErrorLog "logs/xiaoyu_error.log"
CustomLog "logs/xiaoyu_custom.log" common
</VirtualHost>
解决方案
- 如果域名配置到某个目录后访问报不允许访问,按如下形式修改:
<VirtualHost www.res.com:80>
DocumentRoot "D:\mynote\mynote_res"
ServerName www.res.com
ErrorLog "logs/res.log"
CustomLog "logs/res_err.log" common
<Directory "D:\mynote\mynote_res">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>