在Apacheconfiguration中使用常量variables

<VirtualHost *:80> SetEnv SITENAME testing ServerName www.test.com # Location of files DocumentRoot "/www/${SITENAME}/site" Alias /data "/www/data/${SITENAME}" Alias /base "/www/${SITENAME}/base/site" # Logging ErrorLog "/var/log/httpd/${SITENAME}-error.log" CustomLog "/var/log/httpd/${SITENAME}-access.log" combined </VirtualHost> 
  • 启动apache2 …警告:DocumentRoot [/ www / $ {SITENAME} /站点]不存在

对文档的进一步阅读提供了一个提示,即SetEnv可能不能及时绑定到path中,build议的替代SetEnvIf也是基于请求属性。

我也看到了使用mod_vhost_alias的例子,但似乎并没有处理任何东西,但DocumentRoot,即使如此,它需要使用服务器名称,这是不是我想要的组件。

我想要的是纯粹的variablesreplace可用的configuration是读取和可用的任何string(如C中的#DEFINE)。 我的Apache版本是2.2。 可以这样做吗?

更新:我在文档中发现了一个Define指令,但它不起作用(看起来像2.3是新的)。 我想现在的问题是有一个模块,将此function还是等同于2.2?

这已经被问过。 链接在这里:

在Apacheconfiguration文件中使用variables来减less重复?