【问题标题】:Setting the subdomain as a variable in apache config to be used in the same config file:将子域设置为 apache config 中的变量以在同一配置文件中使用:
【发布时间】:2016-07-12 00:26:44
【问题描述】:
  1. 如何将通配符地址的子域动态定义为apache配置文件中的变量?
  2. 如何在apache的配置文件中调用环境变量? 这个选项在这里不起作用: Create an Apache SetEnv variable with the subdomain name in case of wildcard 好像不行。

我试过了:

设置环境病毒:

  • SetEnv SUBDOMAIN 子域x
  • SetEnvIf 主机 "^([^.]*).domainx.tldx$" SUBDOMAIN=$1
  • SetEnvIf 主机 "^([^.]*).domainx.tldx$" SUBDOMAIN=specificsubdomainx
  • 定义子域 %-3

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

  • ${SUBDOMAIN}
  • %{SUBDOMAIN}
  • 子域

请帮忙,这把我吓坏了。谢谢

【问题讨论】:

  • 所以,现在我知道要在 apache 配置中使用的环境变量应该导出并在“envvars”文件中定义。但是那里的 apache 模块不起作用。我试过了:`export SetEnvIf Remote_Addr "^" subdomainx=subdomainx` 还是不行

标签: apache environment-variables subdomain wildcard


【解决方案1】:
SetEnvIf Host "^([^.]*).domainx.tldx$" SUBDOMAIN=$1

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

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

%{ENV:SUBDOMAIN}

【讨论】:

  • 我有完全相同的东西,但它不工作,仍在打印 %{ENV:SUBDOMAIN}
猜你喜欢
  • 1970-01-01
  • 2014-01-07
  • 2014-08-14
  • 1970-01-01
  • 1970-01-01
  • 2013-09-03
  • 2014-01-04
  • 2016-01-14
  • 2014-09-02
相关资源
最近更新 更多