带 Include 指令的动态 VirtualHost

带 Include 指令的动态 VirtualHost

我正在尝试根据以下配置来考虑 Apache 配置:文档其中每个虚拟主机本质上都是相同的,但我想添加一个指向配置文件的包含指令来区分每个虚拟主机,允许配置存在差异,而无需使用 htaccess 文件。

# get the server name from the Host: header
UseCanonicalName Off

# this log format can be split per-virtual-host based on the first field
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
CustomLog logs/access_log vcommon

# include the server name in the filenames used to satisfy requests
VirtualDocumentRoot /www/hosts/%0/docs
VirtualScriptAlias /www/hosts/%0/cgi-bin

但我想我不能添加Include /www/hosts/conf/%0.conf或类似的东西?

有没有什么标准的方法可以做到这一点?

答案1

包括文件中,您可以根据需要为每个从默认设置修改的 virthost 定义 Virtualhost 容器。这不是标准的,但广泛采用的做法

我使用它,发现维护 1 个文件比维护一长套文件更容易

相关内容