我似乎无法在本地 Apache 安装上使用通配符虚拟主机。我的虚拟主机文件当前包含以下内容。编辑后,我确保重新启动服务器,但仍然无法让它工作。
基本上,我试图让 *.joshholat.local 指向不同于 joshholat.local 的地方,只是为了确保配置正常工作。
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/opt/local/www"
ServerName joshholat.local
ErrorLog "logs/error.log"
CustomLog "logs/access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/opt/local/www/phpmyadmin"
ServerName joshholat.local
ServerAlias *.joshholat.local
ErrorLog "logs/error.log"
CustomLog "logs/access.log" common
</VirtualHost>
答案1
现在你有两个具有相同ServerName
指令的虚拟主机
改变
ServerName joshholat.local
在第二个虚拟主机中
ServerName www.joshholat.local
我可能还会为每个虚拟主机设置不同的日志文件
因此你的配置如下:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/opt/local/www"
ServerName joshholat.local
ErrorLog "logs/error.log"
CustomLog "logs/access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/opt/local/www/phpmyadmin"
ServerName www.joshholat.local
ServerAlias *.joshholat.local
ErrorLog "logs/phpmyadmin_error.log"
CustomLog "logs/phpmyadmin_access.log" common
</VirtualHost>