我的虚拟主机设置如下:
<VirtualHost *:8080>
ServerName localhost
DocumentRoot "D:\xampp\htdocs"
<Directory "D:\xampp\htdocs">
DirectoryIndex index.php
</Directory>
</VirtualHost>
<VirtualHost *:8080>
ServerName mysite.site
DocumentRoot "D:\xampp\htdocs\mysite"
SetEnv APPLICATION_ENV "development"
<Directory "D:\xampp\htdocs\mysite\public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
和主机文件:
127.0.0.1 localhost
127.0.0.1 mysite.site
,但实际上不起作用。我必须经过localhost/mysite/public
才能使其正常工作。为什么?它没有加载我的站点,而是加载了我的localhost默认站点,即xampp的htdocs文件夹。
编辑:
只是想补充一下,我在httpd.conf中已经有Include conf/extra/httpd-vhosts.conf
。
答案 0 :(得分:0)
好的,我终于明白了。看起来我的端口不正确。我检查了httpd.conf
下ServerName localhost:80
中使用的端口。然后,我修复了虚拟主机设置:
<VirtualHost *:80>
ServerName mysite.site
DocumentRoot "D:/xampp/htdocs/mysite/public"
SetEnv APPLICATION_ENV "development"
<Directory "D:/xampp\htdocs/mysite/public/">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
现在可以使用了。 :)