从Apache2 serverAlias中排除特定的域,同时使用捕获所有*(通配符)别名

我有一个Web应用程序需要支持自定义域,在这方面,我已经设置了以下名称的虚拟服务器:

<VirtualHost *:80> ServerName example.com ServerAlias * *.example.com www.example.com example.com RailsEnv production RackEnv production DocumentRoot /srv/www/example/current/public <Directory /srv/www/example/current/public> AllowOverride all Options -MultiViews FollowSymLinks </Directory> ErrorLog /srv/www/example/log/error.log TransferLog /srv/www/example/log/access.log </VirtualHost> 

注意*作为服务器别名? 捕获该服务器上的所有域。 但是,我有这个服务器上的其他网站,我想从这个列表中排除。 对于我来说,有一个被排除的域列表比手动设置用户可以在这个服务注册的每个域作为serverAlias更加经济…

也许这不是最好的方法,但我正在寻找帮助,以最好(相对简单)的方式来设置一个可以捕捉任何域的Web应用程序,同时允许其他特定的域被路由到不同的应用程序。

Apache按照域定义的顺序search匹配项。 如果我正确地理解了你的问题,那么可以通过在捕获所有主机之前定义要排除的主机来解决。

 <VirtualHost *:80> ServerName excluded.example.com ServerAlias something.example.com ... ... </VirtualHost> <VirtualHost *:80> ServerName example.com ServerAlias * *.example.com www.example.com example.com RailsEnv production ... </VirtualHost>