[英]Configuration file for Apache2 and two websites
I have two domains and this is my configuration file: 我有两个域,这是我的配置文件:
<VirtualHost *:80>
ServerAdmin hello@example.com
DocumentRoot /var/www/html/
ServerName main-site.example
</VirtualHost>
<VirtualHost *:80>
ServerAdmin hello@example.com
DocumentRoot /var/www/example.com/public_html/
ServerName second-site.example
</VirtualHost>
What I do not understand is this: 我不明白的是:
main-site.example
and www.main-site.example
are accesible and point at main-site.example
, so this is ok main-site.example
和main-site.example
www.main-site.example
并指向main-site.example
,所以可以 www.second-site.example
points to main-site.example
only if I do second-site.example
it works and I do not understand why www.second-site.example
指向main-site.example
仅在我执行second-site.example
时有效,并且我不理解为什么 Add the ServerAlias
directive to define your virtualHosts. 添加
ServerAlias
指令以定义您的virtualHosts。 Otherwise Apache will match www.second-site.example
with the first *:80
VirtualHost
. 否则,Apache将
www.second-site.example
与第一个*:80
VirtualHost
匹配。
<VirtualHost *:80>
ServerName main-site.example
ServerAlias www.main-site.example
ServerAdmin hello@example.com
DocumentRoot /var/www/html/
</VirtualHost>
<VirtualHost *:80>
ServerName second-site.example
ServerAlias www.second-site.example
ServerAdmin hello@example.com
DocumentRoot /var/www/example.com/public_html/
</VirtualHost>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.