'How to use <If> <ElseIf> <Else> in Apache with custom variables?

Define FOO "/bar/foo/bar_v1.0.0"

<If "${FOO} == '/bar/foo/bar_v1.0.0'">
    Define BAR2 "foofoo1"
</If>
<ElseIf "${FOO} == '/bar/foo/bar_v2.0.0'">
    Define BAR2 "foofoo2"
</ElseIf>
<Else>
    Define BAR2 "foofoo3"
</Else>

What I do wrong? I've read the Apache docs and this one too, but I can't see the problem.

• I've tried '${FOO}', ${FOO}, '%{FOO}', %{FOO}.

• I've tried to remove quotes from the string: <If "${FOO} == /bar/foo/bar_v1.0.0">

• I've tried to remove double quotes at all: <If ${FOO} == '/bar/foo/bar_v1.0.0'>

• I've also tried <If "${FOO} =~ /bar_v1\.0\.0/"> and

<If "${FOO} -strmatch '/bar/foo/bar.v1.0.0'">

• I've also tried quote marks removed from the values that are set with the Define directive:

Define FOO /bar/foo/bar_v1.0.0

• I've tried to remove ElseIf block, and use just If and Else

And I always get BAR2 defined as a "foofoo3", cuz it just an exception (default) value I put in "else", just in case. So first two block never work no matter what.

I don't get it, can I even use custom variables in Apache expressions? The code is located in Apache config file.


I'm getting Apache error and it doesn't start. The error is because I use BAR2 as a part of a path to load module. Of course Apache says it cannot load module, because actually I do not have such path "/usr/foofoo3/some_module" but I certainly have "/usr/foofoo1/some_module" and "/usr/foofoo2/some_module", but as I said first 2 blocks never work



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source