<title>Expressions in Apache HTTP Server</title>
<summary>
- <p>Historically, there are several syntax variants for expressions used to express
- a condition in the different modules of the Apache HTTP Server.
- There is some ongoing effort to only use a single variant, called <em>ap_expr</em>,
- for all configuration directives.
- This document describes the <em>ap_expr</em> expression parser.
+ <p>Historically, there are several syntax variants for expressions
+ used to express a condition in the different modules of the Apache
+ HTTP Server. There is some ongoing effort to only use a single
+ variant, called <em>ap_expr</em>, for all configuration directives.
+ This document describes the <em>ap_expr</em> expression parser.
</p>
<p>The <em>ap_expr</em> expression is intended to replace most other
- expression variants in HTTPD. For example, the deprecated
- <directive module="mod_ssl">SSLRequire</directive> expressions can be
- replaced by <a href="mod/mod_authz_core.html#reqexpr">Require expr</a>.
- </p>
+ expression variants in HTTPD. For example, the deprecated <directive
+ module="mod_ssl">SSLRequire</directive> expressions can be replaced
+ by <a href="mod/mod_authz_core.html#reqexpr">Require expr</a>. </p>
</summary>
<seealso><directive module="core" type="section">If</directive></seealso>
<section id="grammar">
<title>Grammar in Backus-Naur Form notation</title>
- <p><a href="http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form">Backus-Naur Form</a> (BNF) is a notation
- technique for context-free grammars, often used to describe the syntax of languages used in computing.
+ <p><a
+ href="http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form">Backus-Naur
+ Form</a> (BNF) is a notation technique for context-free grammars,
+ often used to describe the syntax of languages used in computing.
In most cases, expressions are used to express boolean values.
- For these, the starting point in the BNF is <code>expr</code>. However, a few directives
- like <directive module="mod_log_debug">LogMessage</directive> accept expressions
- that evaluate to a string value. For those, the starting point in the BNF is <code>string</code>.
+ For these, the starting point in the BNF is <code>expr</code>.
+ However, a few directives like <directive
+ module="mod_log_debug">LogMessage</directive> accept expressions
+ that evaluate to a string value. For those, the starting point in
+ the BNF is <code>string</code>.
</p>
<blockquote>
<pre>
<td>The <directive module="core">DocumentRoot</directive> of
the current vhost</td></tr>
<tr><td><code>AUTH_TYPE</code></td>
- <td>The configured <directive module="mod_authn_core">AuthType</directive>
- (e.g. "<code>basic</code>")</td></tr>
+ <td>The configured <directive
+ module="mod_authn_core">AuthType</directive> (e.g.
+ "<code>basic</code>")</td></tr>
<tr><td><code>CONTENT_TYPE</code></td>
<td>The content type of the response</td></tr>
<tr><td><code>HANDLER</code></td>
<td>The day of the week (starting with <code>0</code>
for Sunday)</td></tr>
<tr><td><code>TIME</code></td>
- <td>The date and time in the format <code>20101231235959</code></td></tr>
+ <td>The date and time in the format
+ <code>20101231235959</code></td></tr>
<tr><td><code>SERVER_SOFTWARE</code></td>
<td>The server version string</td></tr>
<tr><td><code>API_VERSION</code></td>
<td>The date of the API version (module magic number)</td></tr>
</table>
- <p>Some modules register additional variables, see e.g. <module>mod_ssl</module>.</p>
+ <p>Some modules register additional variables, see e.g.
+ <module>mod_ssl</module>.</p>
</section>
"<code>false</code>", or "<code>no</code>" (case insensitive).
True otherwise.</td><td></td></tr>
<tr><td><code>-R</code></td>
- <td>Same as "<code>%{REMOTE_ADDR} -ipmatch ...</code>", but more efficient
+ <td>Same as "<code>%{REMOTE_ADDR} -ipmatch ...</code>", but more
+ efficient
</td><td></td></tr>
</table>
Modules may register additional functions.</p>
<table border="1" style="zebra">
- <columnspec><column width=".2"/><column width=".8"/></columnspec>
+ <columnspec><column width=".2"/><column width=".4"/><column width=".4"/></columnspec>
<tr><th>Name</th><th>Description</th><th>Restricted</th></tr>
<tr><td><code>req</code>, <code>http</code></td>
<tr><td><code>resp</code></td>
<td>Get HTTP response header</td><td></td></tr>
<tr><td><code>reqenv</code></td>
- <td>Lookup request environment variable (as a shortcut, <code>v</code> can be used too to access variables).</td><td></td></tr>
+ <td>Lookup request environment variable (as a shortcut,
+ <code>v</code> can be used too to access
+ variables).</td><td></td></tr>
<tr><td><code>osenv</code></td>
<td>Lookup operating system environment variable</td><td></td></tr>
<tr><td><code>note</code></td>
the expression. The <code>req_novary</code> function can be used to
prevent names from being added to the Vary header.</p>
- <p>In addition to string-valued functions, there are also list-valued functions which
- take one string as argument and return a wordlist, i.e. a list of strings. The wordlist
- can be used with the special <code>-in</code> operator.
- Functions names are not case sensitive.
- Modules may register additional functions.</p>
+ <p>In addition to string-valued functions, there are also
+ list-valued functions which take one string as argument and return a
+ wordlist, i.e. a list of strings. The wordlist can be used with the
+ special <code>-in</code> operator. Functions names are not case
+ sensitive. Modules may register additional functions.</p>
<p>There are no built-in list-valued functions. <module>mod_ssl</module>
provides <code>PeerExtList</code>. See the description of
<section id="examples">
<title>Example expressions</title>
- <p>The following examples show how expressions might be used to evaluate requests:</p>
+ <p>The following examples show how expressions might be used to
+ evaluate requests:</p>
<!-- This section should probably be extended with more, useful examples -->
<highlight language="config">
# Compare the host name to example.com and redirect to www.example.com if it matches
<td>string contained in string list</td></tr>
<tr><td><code>/regexp/</code></td>
<td><code>m#regexp#</code></td>
- <td>Regular expression (the second form allows different delimiters than /)</td></tr>
+ <td>Regular expression (the second form allows different
+ delimiters than /)</td></tr>
<tr><td><code>/regexp/i</code></td>
<td><code>m#regexp#i</code></td>
<td>Case insensitive regular expression</td></tr>