mrjayviper
mrjayviper

Reputation: 2388

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

Here's my code (I've commented out the if-else part as it's not working)

snippets/contents of my config files

/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} can have 3 possible values: main or staff or customer

I have tried:

Thanks!

edit: I was using this page as guide.

Upvotes: 2

Views: 4059

Answers (1)

Rarblack
Rarblack

Reputation: 4664

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

Take a look at Expressions in Apache HTTP Server.

EDIT :

if host_domain is not a self created variable make all upper case ${HOST_DOMAIN}.

and wrap it with single quotations:

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

Take a look at this.

Upvotes: 2

Related Questions