如何在 Apache 配置中的 If-Else 语句中使用自定义变量?

How do I use a custom variable in an If-Else statement inside an Apache config?

这是我的代码(我已经注释掉了 if-else 部分,因为它不起作用)

snippets/contents 个我的配置文件

/etc/httpd/conf.d/staff.vhost

Define host_domain "staff"

Include /etc/httpd/conf.d/stage_template.vhost

/etc/httpd/conf.d/stage_template.vhost

    #<If "${host_domain} == 'main'">
    #    ServerAlias stage.myhost.com
    #</If>
    #<Else>
        ServerAlias stage-${host_domain}.myhost.com
    #</Else>

${host_domain} 可以有 3 个可能的值:主要或员工或客户

我试过:

谢谢!

编辑:我使用这个 page 作为指南。

<If "false">
...
</If>

看看Expressions in Apache HTTP Server

编辑:

如果host_domain不是自己创建的变量全部大写${HOST_DOMAIN}.

并用单引号括起来:

#<If "'${host_domain}' == 'main'">

看看this