7

We can use Apache's IfModule directive to test presence or absence of a specific module. Apache also allows nested IfModule directives which can be used to test multiple modules, in other words we can implement logic AND.

Is it also possible to implement logic OR? For example is it possible to use something similar to this:

<IfModule mod_php5.c OR sapi_apache2.c>
    # Some directives
</IfModule>

Instead of this:

<IfModule mod_php5.c>
    # Some directives
</IfModule>
<IfModule sapi_apache2.c>
    # Absolutely same directives with mod_php.c
</IfModule>

3 Answers 3

3

While it's not perfect, you could put the directives you want into a separate file, and then Include it in the relevant locations. I don't believe there's a way to do a logical OR in a single IfModule statement.

1
  • Although it's not perfect, it's definitely a solution. Jul 15, 2011 at 12:09
0

This is what I came up with:

<IfModule mod_php5.c>
    # Some directives
</IfModule>
<IfModule sapi_apache2.c>
    <IfModule !mod_php5.c>
        # Absolutely same directives with mod_php.c
    </IfModule>
</IfModule>
-1

<IfModule> sections are nest-able, which can be used to implement simple multiple-module tests.

http://httpd.apache.org/docs/2.4/mod/core.html#ifmodule

Not sure since when it's available.

1
  • 1
    This can only be used for AND tests. Orginal post is about OR tests. Jun 25, 2019 at 3:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .