将子域设置为要在同一配置文件中使用的 apache 配置中的变量:

Setting the subdomain as a variable in apache config to be used in the same config file:

  1. 如何在 apache 配置文件中将通配符地址的子域动态定义为变量?
  2. 如何调用apache配置文件中的环境变量? 此选项在这里不起作用: Create an Apache SetEnv variable with the subdomain name in case of wildcard 好像不行。

我试过:

设置环境可行:

正在同一配置文件中检索变量:

请帮忙,我吓坏了。谢谢

SetEnvIf Host "^([^.]*).domainx.tldx$" SUBDOMAIN=

看起来不错(前提是您使用的域是 *.domainx.tldx)

但是你必须像这样引用变量:

%{ENV:SUBDOMAIN}