使用相同的 DocumentRoot 设置多个 Apache2 VirtualHosts?

使用相同的 DocumentRoot 设置多个 Apache2 VirtualHosts?

我正在尝试完成这样的事情

DocumentRoot /www/_offline.com

<VirtualHost *:80>
      ServerName example1.com
      ServerAlias www.example1.com
</VirtualHost>

<VirtualHost *:80>
      ServerName example2.com
      ServerAlias www.example2.com
      DocumentRoot /www/_offline.com
</VirtualHost>

不同的域可以有一个 documentRoot 吗?

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
         default server localhost (/etc/apache2/sites-enabled/000-default:1)
         port 80 namevhost localhost (/etc/apache2/sites-enabled/000-default:1)
         port 80 namevhost aa.atd (/etc/apache2/sites-enabled/all-phoenix-domains:2)
         port 80 namevhost atd.atd (/etc/apache2/sites-enabled/all-phoenix-domains:13)
         port 80 namevhost test (/etc/apache2/sites-enabled/test:1)
Syntax OK

答案1

没问题。但我宁愿使用多个 serverAlias。

相关内容