2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
7 Licensed to the Apache Software Foundation (ASF) under one or more
8 contributor license agreements. See the NOTICE file distributed with
9 this work for additional information regarding copyright ownership.
10 The ASF licenses this file to You under the Apache License, Version 2.0
11 (the "License"); you may not use this file except in compliance with
12 the License. You may obtain a copy of the License at
14 http://www.apache.org/licenses/LICENSE-2.0
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
23 <modulesynopsis metafile="mod_version.xml.meta">
24 <name>mod_version</name>
25 <description>Version dependent configuration</description>
26 <status>Extension</status>
27 <sourcefile>mod_version.c</sourcefile>
28 <identifier>version_module</identifier>
31 <p>This module is designed for the use in test suites and large
32 networks which have to deal with different httpd versions and
33 different configurations. It provides a new container -- <directive
34 type="section" module="mod_version">IfVersion</directive>, which
35 allows a flexible version checking including numeric comparisons and
36 regular expressions.</p>
38 <example><title>Examples</title>
39 <highlight language="config">
40 <IfVersion 2.4.2>
41 # current httpd version is exactly 2.4.2
44 <IfVersion >= 2.5>
45 # use really new features :-)
50 <p>See below for further possibilities.</p>
53 <directivesynopsis type="section">
54 <name>IfVersion</name>
55 <description>contains version dependent configuration</description>
56 <syntax><IfVersion [[!]<var>operator</var>] <var>version</var>> ...
57 </IfVersion></syntax>
58 <contextlist><context>server config</context><context>virtual host</context>
59 <context>directory</context><context>.htaccess</context></contextlist>
60 <override>All</override>
63 <p>The <directive type="section">IfVersion</directive> section encloses
64 configuration directives which are executed only if the
65 <program>httpd</program> version
66 matches the desired criteria. For normal (numeric) comparisons the
67 <var>version</var> argument has the format
68 <code><var>major</var>[.<var>minor</var>[.<var>patch</var>]]</code>, e.g.
69 <code>2.1.0</code> or <code>2.2</code>. <var>minor</var> and
70 <var>patch</var> are optional. If these numbers are omitted, they are
71 assumed to be zero. The following numerical <var>operator</var>s are
74 <table style="zebra" border="1">
75 <tr><th><var>operator</var></th><th>description</th></tr>
76 <tr><td><code>=</code> or <code>==</code></td>
77 <td>httpd version is equal</td></tr>
78 <tr><td><code>></code></td>
79 <td>httpd version is greater than</td></tr>
80 <tr><td><code>>=</code></td>
81 <td>httpd version is greater or equal</td></tr>
82 <tr><td><code><</code></td>
83 <td>httpd version is less than</td></tr>
84 <tr><td><code><=</code></td>
85 <td>httpd version is less or equal</td></tr>
88 <example><title>Example</title>
89 <highlight language="config">
90 <IfVersion >= 2.3>
91 # this happens only in versions greater or
97 <p>Besides the numerical comparison it is possible to match a
98 <glossary ref="regex">regular expression</glossary>
99 against the httpd version. There are two ways to write it:</p>
101 <table style="zebra" border="1">
102 <tr><th><var>operator</var></th><th>description</th></tr>
103 <tr><td><code>=</code> or <code>==</code></td>
104 <td><var>version</var> has the form
105 <code>/<var>regex</var>/</code></td></tr>
106 <tr><td><code>~</code></td>
107 <td><var>version</var> has the form
108 <code><var>regex</var></code></td></tr>
111 <example><title>Example</title>
112 <highlight language="config">
113 <IfVersion = /^2.4.[01234]$/>
114 # e.g. workaround for buggy versions
119 <p>In order to reverse the meaning, all operators can be preceded by an
120 exclamation mark (<code>!</code>):</p>
122 <highlight language="config">
123 <IfVersion !~ ^2.4.[01234]$>
124 # not for those versions
128 <p>If the <var>operator</var> is omitted, it is assumed to be