]> granicus.if.org Git - apache/blob - docs/manual/expr.xml
Remove useless <br \> in highlight blocks.
[apache] / docs / manual / expr.xml
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE manualpage SYSTEM "./style/manualpage.dtd">
3 <?xml-stylesheet type="text/xsl" href="./style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
5
6 <!--
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
13
14      http://www.apache.org/licenses/LICENSE-2.0
15
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.
21 -->
22
23 <manualpage metafile="expr.xml.meta">
24
25   <title>Expressions in Apache HTTP Server</title>
26
27   <summary>
28     <p>Historically, there are several syntax variants for expressions
29     used to express a condition in the different modules of the Apache
30     HTTP Server.  There is some ongoing effort to only use a single
31     variant, called <em>ap_expr</em>, for all configuration directives.
32     This document describes the <em>ap_expr</em> expression parser.
33     </p>
34     <p>The <em>ap_expr</em> expression is intended to replace most other
35     expression variants in HTTPD. For example, the deprecated <directive
36     module="mod_ssl">SSLRequire</directive> expressions can be replaced
37     by <a href="mod/mod_authz_core.html#reqexpr">Require expr</a>.  </p>
38   </summary>
39
40 <seealso><directive module="core" type="section">If</directive></seealso>
41 <seealso><directive module="core" type="section">ElseIf</directive></seealso>
42 <seealso><directive module="core" type="section">Else</directive></seealso>
43 <seealso><directive module="core">ErrorDocument</directive></seealso>
44 <seealso><directive module="mod_alias">Alias</directive></seealso>
45 <seealso><directive module="mod_alias">ScriptAlias</directive></seealso>
46 <seealso><directive module="mod_alias">Redirect</directive></seealso>
47 <seealso><directive module="mod_auth_basic">AuthBasicFake</directive></seealso>
48 <seealso><directive module="mod_auth_form">AuthFormLoginRequiredLocation</directive></seealso>
49 <seealso><directive module="mod_auth_form">AuthFormLoginSuccessLocation</directive></seealso>
50 <seealso><directive module="mod_auth_form">AuthFormLogoutLocation</directive></seealso>
51 <seealso><directive module="mod_rewrite">RewriteCond</directive></seealso>
52 <seealso><directive module="mod_setenvif">SetEnvIfExpr</directive></seealso>
53 <seealso><directive module="mod_headers">Header</directive></seealso>
54 <seealso><directive module="mod_headers">RequestHeader</directive></seealso>
55 <seealso><directive module="mod_filter">FilterProvider</directive></seealso>
56 <seealso><a href="mod/mod_authz_core.html#reqexpr">Require expr</a></seealso>
57 <seealso><a href="mod/mod_authnz_ldap.html#requser">Require ldap-user</a></seealso>
58 <seealso><a href="mod/mod_authnz_ldap.html#reqgroup">Require ldap-group</a></seealso>
59 <seealso><a href="mod/mod_authnz_ldap.html#reqdn">Require ldap-dn</a></seealso>
60 <seealso><a href="mod/mod_authnz_ldap.html#reqattribute">Require ldap-attribute</a></seealso>
61 <seealso><a href="mod/mod_authnz_ldap.html#reqfilter">Require ldap-filter</a></seealso>
62 <seealso><a href="mod/mod_authz_dbd.html#reqgroup">Require dbd-group</a></seealso>
63 <seealso><a href="mod/mod_authz_dbm.html#reqgroup">Require dbm-group</a></seealso>
64 <seealso><a href="mod/mod_authz_groupfile.html#reqgroup">Require group</a></seealso>
65 <seealso><a href="mod/mod_authz_host.html#reqhost">Require host</a></seealso>
66 <seealso><directive module="mod_ssl">SSLRequire</directive></seealso>
67 <seealso><directive module="mod_log_debug">LogMessage</directive></seealso>
68 <seealso><module>mod_include</module></seealso>
69
70   <section id="grammar">
71     <title>Grammar in Backus-Naur Form notation</title>
72       <p><a
73       href="http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form">Backus-Naur
74       Form</a> (BNF) is a notation technique for context-free grammars,
75       often used to describe the syntax of languages used in computing.
76       In most cases, expressions are used to express boolean values.
77       For these, the starting point in the BNF is <code>expr</code>.
78       However, a few directives like <directive
79       module="mod_log_debug">LogMessage</directive> accept expressions
80       that evaluate to a string value. For those, the starting point in
81       the BNF is <code>string</code>.
82       </p>
83 <blockquote>
84 <pre>
85 expr        ::= "<strong>true</strong>" | "<strong>false</strong>"
86               | "<strong>!</strong>" expr
87               | expr "<strong>&amp;&amp;</strong>" expr
88               | expr "<strong>||</strong>" expr
89               | "<strong>(</strong>" expr "<strong>)</strong>"
90               | comp
91
92 comp        ::= stringcomp
93               | integercomp
94               | unaryop word
95               | word binaryop word
96               | word "<strong>in</strong>" "<strong>{</strong>" wordlist "<strong>}</strong>"
97               | word "<strong>in</strong>" listfunction
98               | word "<strong>=~</strong>" regex
99               | word "<strong>!~</strong>" regex
100
101
102 stringcomp  ::= word "<strong>==</strong>" word
103               | word "<strong>!=</strong>" word
104               | word "<strong>&lt;</strong>"  word
105               | word "<strong>&lt;=</strong>" word
106               | word "<strong>&gt;</strong>"  word
107               | word "<strong>&gt;=</strong>" word
108
109 integercomp ::= word "<strong>-eq</strong>" word | word "<strong>eq</strong>" word
110               | word "<strong>-ne</strong>" word | word "<strong>ne</strong>" word
111               | word "<strong>-lt</strong>" word | word "<strong>lt</strong>" word
112               | word "<strong>-le</strong>" word | word "<strong>le</strong>" word
113               | word "<strong>-gt</strong>" word | word "<strong>gt</strong>" word
114               | word "<strong>-ge</strong>" word | word "<strong>ge</strong>" word
115
116 wordlist    ::= word
117               | wordlist "<strong>,</strong>" word
118
119 word        ::= word "<strong>.</strong>" word
120               | digit
121               | "<strong>'</strong>" string "<strong>'</strong>"
122               | "<strong>"</strong>" string "<strong>"</strong>"
123               | variable
124               | rebackref
125               | function
126
127 string      ::= stringpart
128               | string stringpart
129
130 stringpart  ::= cstring
131               | variable
132               | rebackref
133
134 cstring     ::= ...
135 digit       ::= [0-9]+
136
137 variable    ::= "<strong>%{</strong>" varname "<strong>}</strong>"
138               | "<strong>%{</strong>" funcname "<strong>:</strong>" funcargs "<strong>}</strong>"
139
140 rebackref   ::= "<strong>$</strong>" [0-9]
141
142 function     ::= funcname "<strong>(</strong>" word "<strong>)</strong>"
143
144 listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
145 </pre>
146 </blockquote>
147
148 </section>
149
150 <section id="vars">
151     <title>Variables</title>
152
153     <p>The expression parser provides a number of variables of the form
154     <code>%{HTTP_HOST}</code>. Note that the value of a variable may depend
155     on the phase of the request processing in which it is evaluated.  For
156     example, an expression used in an <directive>&lt;If &gt;</directive>
157     directive is evaluated before authentication is done. Therefore,
158     <code>%{REMOTE_USER}</code> will not be set in this case.</p>
159
160     <p>The following variables provide the values of the named HTTP request
161     headers. The values of other headers can be obtained with the
162     <code>req</code> <a href="#functions">function</a>. Using these
163     variables may cause the header name to be added to the Vary
164     header of the HTTP response, except where otherwise noted for the
165     directive accepting the expression. The <code>req_novary</code>
166     <a href="#functions">function</a> may be used to circumvent this
167     behavior.</p>
168
169     <table border="1" style="zebra">
170     <columnspec><column width="1"/></columnspec>
171
172     <tr><th>Name</th></tr>
173     <tr><td><code>HTTP_ACCEPT</code></td></tr>
174     <tr><td><code>HTTP_COOKIE</code></td></tr>
175     <tr><td><code>HTTP_FORWARDED</code></td></tr>
176     <tr><td><code>HTTP_HOST</code></td></tr>
177     <tr><td><code>HTTP_PROXY_CONNECTION</code></td></tr>
178     <tr><td><code>HTTP_REFERER</code></td></tr>
179     <tr><td><code>HTTP_USER_AGENT</code></td></tr>
180
181     </table>
182
183     <p>Other request related variables</p>
184
185     <table border="1" style="zebra">
186     <columnspec><column width=".4"/><column width=".6"/></columnspec>
187
188     <tr><th>Name</th><th>Description</th></tr>
189     <tr><td><code>REQUEST_METHOD</code></td>
190         <td>The HTTP method of the incoming request (e.g.
191             <code>GET</code>)</td></tr>
192     <tr><td><code>REQUEST_SCHEME</code></td>
193         <td>The scheme part of the request's URI</td></tr>
194     <tr><td><code>REQUEST_URI</code></td>
195         <td>The path part of the request's URI</td></tr>
196     <tr><td><code>DOCUMENT_URI</code></td>
197         <td>Same as <code>REQUEST_URI</code></td></tr>
198     <tr><td><code>REQUEST_FILENAME</code></td>
199         <td>The full local filesystem path to the file or script matching the
200             request, if this has already been determined by the server at the
201             time <code>REQUEST_FILENAME</code> is referenced. Otherwise, such
202             as when used in virtual host context, the same value as
203             <code>REQUEST_URI</code> </td></tr>
204     <tr><td><code>SCRIPT_FILENAME</code></td>
205         <td>Same as <code>REQUEST_FILENAME</code></td></tr>
206     <tr><td><code>LAST_MODIFIED</code></td>
207         <td>The date and time of last modification of the file in the format
208             <code>20101231235959</code>, if this has already been determined by
209             the server at the time <code>LAST_MODIFIED</code> is referenced.
210             </td></tr>
211     <tr><td><code>SCRIPT_USER</code></td>
212         <td>The user name of the owner of the script.</td></tr>
213     <tr><td><code>SCRIPT_GROUP</code></td>
214         <td>The group name of the group of the script.</td></tr>
215     <tr><td><code>PATH_INFO</code></td>
216         <td>The trailing path name information, see
217             <directive module="core">AcceptPathInfo</directive></td></tr>
218     <tr><td><code>QUERY_STRING</code></td>
219         <td>The query string of the current request</td></tr>
220     <tr><td><code>IS_SUBREQ</code></td>
221         <td>"<code>true</code>" if the current request is a subrequest,
222             "<code>false</code>" otherwise</td></tr>
223     <tr><td><code>THE_REQUEST</code></td>
224         <td>The complete request line (e.g.,
225             "<code>GET /index.html HTTP/1.1</code>")</td></tr>
226     <tr><td><code>REMOTE_ADDR</code></td>
227         <td>The IP address of the remote host</td></tr>
228     <tr><td><code>REMOTE_HOST</code></td>
229         <td>The host name of the remote host</td></tr>
230     <tr><td><code>REMOTE_USER</code></td>
231         <td>The name of the authenticated user, if any (not available during <directive>&lt;If &gt;</directive>)</td></tr>
232     <tr><td><code>REMOTE_IDENT</code></td>
233         <td>The user name set by <module>mod_ident</module></td></tr>
234     <tr><td><code>SERVER_NAME</code></td>
235         <td>The <directive module="core">ServerName</directive> of
236             the current vhost</td></tr>
237     <tr><td><code>SERVER_PORT</code></td>
238         <td>The server port of the current vhost, see
239             <directive module="core">ServerName</directive></td></tr>
240     <tr><td><code>SERVER_ADMIN</code></td>
241         <td>The <directive module="core">ServerAdmin</directive> of
242             the current vhost</td></tr>
243     <tr><td><code>SERVER_PROTOCOL</code></td>
244         <td>The protocol used by the request</td></tr>
245     <tr><td><code>DOCUMENT_ROOT</code></td>
246         <td>The <directive module="core">DocumentRoot</directive> of
247             the current vhost</td></tr>
248     <tr><td><code>AUTH_TYPE</code></td>
249         <td>The configured <directive
250         module="mod_authn_core">AuthType</directive> (e.g.
251         "<code>basic</code>")</td></tr>
252     <tr><td><code>CONTENT_TYPE</code></td>
253         <td>The content type of the response (not available during <directive>&lt;If &gt;</directive>)</td></tr>
254     <tr><td><code>HANDLER</code></td>
255         <td>The name of the <a href="handler.html">handler</a> creating
256             the response</td></tr>
257     <tr><td><code>HTTP2</code></td>
258         <td>"<code>on</code>" if the request uses http/2,
259             "<code>off</code>" otherwise</td></tr>
260     <tr><td><code>HTTPS</code></td>
261         <td>"<code>on</code>" if the request uses https,
262             "<code>off</code>" otherwise</td></tr>
263     <tr><td><code>IPV6</code></td>
264         <td>"<code>on</code>" if the connection uses IPv6,
265             "<code>off</code>" otherwise</td></tr>
266     <tr><td><code>REQUEST_STATUS</code></td>
267         <td>The HTTP error status of the request (not available during <directive>&lt;If &gt;</directive>)</td></tr>
268     <tr><td><code>REQUEST_LOG_ID</code></td>
269         <td>The error log id of the request (see
270             <directive module="core">ErrorLogFormat</directive>)</td></tr>
271     <tr><td><code>CONN_LOG_ID</code></td>
272         <td>The error log id of the connection (see
273             <directive module="core">ErrorLogFormat</directive>)</td></tr>
274     <tr><td><code>CONN_REMOTE_ADDR</code></td>
275         <td>The peer IP address of the connection (see the
276             <module>mod_remoteip</module> module)</td></tr>
277     <tr><td><code>CONTEXT_PREFIX</code></td>
278         <td></td></tr>
279     <tr><td><code>CONTEXT_DOCUMENT_ROOT</code></td>
280         <td></td></tr>
281
282     </table>
283
284     <p>Misc variables</p>
285
286     <table border="1" style="zebra">
287     <columnspec><column width=".4"/><column width=".6"/></columnspec>
288
289     <tr><th>Name</th><th>Description</th></tr>
290     <tr><td><code>TIME_YEAR</code></td>
291         <td>The current year (e.g. <code>2010</code>)</td></tr>
292     <tr><td><code>TIME_MON</code></td>
293         <td>The current month (<code>1</code>, ..., <code>12</code>)</td></tr>
294     <tr><td><code>TIME_DAY</code></td>
295         <td>The current day of the month</td></tr>
296     <tr><td><code>TIME_HOUR</code></td>
297         <td>The hour part of the current time
298             (<code>0</code>, ..., <code>23</code>)</td></tr>
299     <tr><td><code>TIME_MIN</code></td>
300         <td>The minute part of the current time </td></tr>
301     <tr><td><code>TIME_SEC</code></td>
302         <td>The second part of the current time </td></tr>
303     <tr><td><code>TIME_WDAY</code></td>
304         <td>The day of the week (starting with <code>0</code>
305             for Sunday)</td></tr>
306     <tr><td><code>TIME</code></td>
307         <td>The date and time in the format
308         <code>20101231235959</code></td></tr>
309     <tr><td><code>SERVER_SOFTWARE</code></td>
310         <td>The server version string</td></tr>
311     <tr><td><code>API_VERSION</code></td>
312         <td>The date of the API version (module magic number)</td></tr>
313     </table>
314
315     <p>Some modules register additional variables, see e.g.
316     <module>mod_ssl</module>.</p>
317
318 </section>
319
320 <section id="binop">
321     <title>Binary operators</title>
322
323     <p>With the exception of some built-in comparison operators, binary
324     operators have the form "<code>-[a-zA-Z][a-zA-Z0-9_]+</code>", i.e. a
325     minus and at least two characters. The name is not case sensitive.
326     Modules may register additional binary operators.</p>
327
328     <section id="comp">
329     <title>Comparison operators</title>
330
331     <table border="1" style="zebra">
332     <columnspec><column width=".2"/><column width=".2"/><column width=".6"/></columnspec>
333
334     <tr><th>Name</th><th>Alternative</th> <th>Description</th></tr>
335     <tr><td><code>==</code></td>
336         <td><code>=</code></td>
337         <td>String equality</td></tr>
338     <tr><td><code>!=</code></td>
339         <td></td>
340         <td>String inequality</td></tr>
341     <tr><td><code>&lt;</code></td>
342         <td></td>
343         <td>String less than</td></tr>
344     <tr><td><code>&lt;=</code></td>
345         <td></td>
346         <td>String less than or equal</td></tr>
347     <tr><td><code>&gt;</code></td>
348         <td></td>
349         <td>String greater than</td></tr>
350     <tr><td><code>&gt;=</code></td>
351         <td></td>
352         <td>String greater than or equal</td></tr>
353     <tr><td><code>-eq</code></td>
354         <td><code>eq</code></td>
355         <td>Integer equality</td></tr>
356     <tr><td><code>-ne</code></td>
357         <td><code>ne</code></td>
358         <td>Integer inequality</td></tr>
359     <tr><td><code>-lt</code></td>
360         <td><code>lt</code></td>
361         <td>Integer less than</td></tr>
362     <tr><td><code>-le</code></td>
363         <td><code>le</code></td>
364         <td>Integer less than or equal</td></tr>
365     <tr><td><code>-gt</code></td>
366         <td><code>gt</code></td>
367         <td>Integer greater than</td></tr>
368     <tr><td><code>-ge</code></td>
369         <td><code>ge</code></td>
370         <td>Integer greater than or equal</td></tr>
371     </table>
372     </section>
373
374     <section id="binaryother">
375     <title>Other binary operators</title>
376
377     <table border="1" style="zebra">
378     <columnspec><column width=".2"/><column width=".8"/></columnspec>
379
380     <tr><th>Name</th><th>Description</th></tr>
381     <tr><td><code>-ipmatch</code></td>
382         <td>IP address matches address/netmask</td></tr>
383     <tr><td><code>-strmatch</code></td>
384         <td>left string matches pattern given by right string (containing
385             wildcards *, ?, [])</td></tr>
386     <tr><td><code>-strcmatch</code></td>
387         <td>same as <code>-strmatch</code>, but case insensitive</td></tr>
388     <tr><td><code>-fnmatch</code></td>
389         <td>same as <code>-strmatch</code>, but slashes are not matched by
390             wildcards</td></tr>
391     </table>
392     </section>
393
394 </section>
395
396 <section id="unnop">
397     <title>Unary operators</title>
398
399     <p>Unary operators take one argument and have the form
400     "<code>-[a-zA-Z]</code>", i.e. a minus and one character.
401     The name <em>is</em> case sensitive.
402     Modules may register additional unary operators.</p>
403
404     <table border="1" style="zebra">
405     <columnspec><column width=".2"/><column width=".2"/><column width=".6"/></columnspec>
406
407     <tr><th>Name</th><th>Description</th><th>Restricted</th></tr>
408     <tr><td><code>-d</code></td>
409         <td>The argument is treated as a filename.
410             True if the file exists and is a directory</td><td>yes</td></tr>
411     <tr><td><code>-e</code></td>
412         <td>The argument is treated as a filename.
413             True if the file (or dir or special) exists</td><td>yes</td></tr>
414     <tr><td><code>-f</code></td>
415         <td>The argument is treated as a filename.
416             True if the file exists and is regular file</td><td>yes</td></tr>
417     <tr><td><code>-s</code></td>
418         <td>The argument is treated as a filename.
419             True if the file exists and is not empty</td><td>yes</td></tr>
420     <tr><td><code>-L</code></td>
421         <td>The argument is treated as a filename.
422             True if the file exists and is symlink</td><td>yes</td></tr>
423     <tr><td><code>-h</code></td>
424         <td>The argument is treated as a filename.
425             True if the file exists and is symlink
426             (same as <code>-L</code>)</td><td>yes</td></tr>
427     <tr><td><code>-F</code></td>
428         <td>True if string is a valid file, accessible via all the server's
429             currently-configured access controls for that path. This uses an
430             internal subrequest to do the check, so use it with care - it can
431             impact your server's performance!</td><td></td></tr>
432     <tr><td><code>-U</code></td>
433         <td>True if string is a valid URL, accessible via all the server's
434             currently-configured access controls for that path. This uses an
435             internal subrequest to do the check, so use it with care - it can
436             impact your server's performance!</td><td></td></tr>
437     <tr><td><code>-A</code></td>
438         <td>Alias for <code>-U</code></td><td></td></tr>
439     <tr><td><code>-n</code></td>
440         <td>True if string is not empty</td><td></td></tr>
441     <tr><td><code>-z</code></td>
442         <td>True if string is empty</td><td></td></tr>
443     <tr><td><code>-T</code></td>
444         <td>False if string is empty, "<code>0</code>", "<code>off</code>",
445             "<code>false</code>", or "<code>no</code>" (case insensitive).
446             True otherwise.</td><td></td></tr>
447     <tr><td><code>-R</code></td>
448         <td>Same as "<code>%{REMOTE_ADDR} -ipmatch ...</code>", but more
449         efficient
450         </td><td></td></tr>
451     </table>
452
453     <p>The operators marked as "restricted" are not available in some modules
454     like <module>mod_include</module>.</p>
455 </section>
456
457 <section id="functions">
458     <title>Functions</title>
459
460     <p>Normal string-valued functions take one string as argument and return
461     a string. Functions names are not case sensitive.
462     Modules may register additional functions.</p>
463
464     <table border="1" style="zebra">
465     <columnspec><column width=".2"/><column width=".4"/><column width=".4"/></columnspec>
466
467     <tr><th>Name</th><th>Description</th><th>Restricted</th></tr>
468     <tr><td><code>req</code>, <code>http</code></td>
469         <td>Get HTTP request header; header names may be added to the Vary
470             header, see below</td><td></td></tr>
471     <tr><td><code>req_novary</code></td>
472         <td>Same as <code>req</code>, but header names will not be added to the
473             Vary header</td><td></td></tr>
474     <tr><td><code>resp</code></td>
475         <td>Get HTTP response header</td><td></td></tr>
476     <tr><td><code>reqenv</code></td>
477         <td>Lookup request environment variable (as a shortcut,
478         <code>v</code> can be used too to access
479         variables).</td><td></td></tr>
480     <tr><td><code>osenv</code></td>
481         <td>Lookup operating system environment variable</td><td></td></tr>
482     <tr><td><code>note</code></td>
483         <td>Lookup request note</td><td></td></tr>
484     <tr><td><code>env</code></td>
485         <td>Return first match of <code>note</code>, <code>reqenv</code>,
486             <code>osenv</code></td><td></td></tr>
487     <tr><td><code>tolower</code></td>
488         <td>Convert string to lower case</td><td></td></tr>
489     <tr><td><code>toupper</code></td>
490         <td>Convert string to upper case</td><td></td></tr>
491     <tr><td><code>escape</code></td>
492         <td>Escape special characters in %hex encoding</td><td></td></tr>
493     <tr><td><code>unescape</code></td>
494         <td>Unescape %hex encoded string, leaving encoded slashes alone;
495             return empty string if %00 is found</td><td></td></tr>
496     <tr><td><code>base64</code></td>
497         <td>Encode the string using base64 encoding</td><td></td></tr>
498     <tr><td><code>unbase64</code></td>
499         <td>Decode base64 encoded string, return truncated string if 0x00 is
500             found</td><td></td></tr>
501     <tr><td><code>md5</code></td>
502         <td>Hash the string using MD5, then encode the hash with hexadecimal
503             encoding</td><td></td></tr>
504     <tr><td><code>sha1</code></td>
505         <td>Hash the string using SHA1, then encode the hash with hexadecimal
506             encoding</td><td></td></tr>
507     <tr><td><code>file</code></td>
508         <td>Read contents from a file (including line endings, when present)
509         </td><td>yes</td></tr>
510     <tr><td><code>filesize</code></td>
511         <td>Return size of a file (or 0 if file does not exist or is not
512             regular file)</td><td>yes</td></tr>
513
514     </table>
515
516     <p>The functions marked as "restricted" are not available in some modules
517     like <module>mod_include</module>.</p>
518
519     <p>When the functions <code>req</code> or <code>http</code> are used,
520     the header name will automatically be added to the Vary header of the
521     HTTP response, except where otherwise noted for the directive accepting
522     the expression. The <code>req_novary</code> function can be used to
523     prevent names from being added to the Vary header.</p>
524
525     <p>In addition to string-valued functions, there are also
526     list-valued functions which take one string as argument and return a
527     wordlist, i.e. a list of strings. The wordlist can be used with the
528     special <code>-in</code> operator.  Functions names are not case
529     sensitive.  Modules may register additional functions.</p>
530
531     <p>There are no built-in list-valued functions. <module>mod_ssl</module>
532     provides <code>PeerExtList</code>.  See the description of
533     <directive module="mod_ssl">SSLRequire</directive> for details
534     (but <code>PeerExtList</code> is also usable outside
535     of <directive module="mod_ssl">SSLRequire</directive>).</p>
536
537 </section>
538
539 <section id="examples">
540     
541         <title>Example expressions</title>
542     <p>The following examples show how expressions might be used to
543     evaluate requests:</p>
544         <!-- This section should probably be extended with more, useful examples -->
545         <highlight language="config">
546 # Compare the host name to example.com and redirect to www.example.com if it matches
547 &lt;If "%{HTTP_HOST} == 'example.com'"&gt;
548     Redirect permanent "/" "http://www.example.com/"
549 &lt;/If&gt;
550
551 # Force text/plain if requesting a file with the query string contains 'forcetext'
552 &lt;If "%{QUERY_STRING} =~ /forcetext/"&gt;
553     ForceType text/plain
554 &lt;/If&gt;
555
556 # Only allow access to this content during business hours
557 &lt;Directory "/foo/bar/business"&gt;
558     Require expr %{TIME_HOUR} -gt 9 &amp;&amp; %{TIME_HOUR} -lt 17
559 &lt;/Directory&gt;      
560
561 # Check a HTTP header for a list of values
562 &lt;If "%{HTTP:X-example-header} in { 'foo', 'bar', 'baz' }"&gt;
563     Header set matched true
564 &lt;/If&gt;
565
566 # Check an environment variable for a regular expression, negated.
567 &lt;If "! reqenv('REDIRECT_FOO') =~ /bar/"&gt;
568     Header set matched true
569 &lt;/If&gt;
570
571 # Check result of URI mapping by running in Directory context with -f
572 &lt;Directory "/var/www"&gt;
573     AddEncoding x-gzip gz
574 &lt;If "-f '%{REQUEST_FILENAME}.unzipme' &amp;&amp; ! %{HTTP:Accept-Encoding} =~ /gzip/"&gt;
575       SetOutputFilter INFLATE
576 &lt;/If&gt;
577 &lt;/Directory&gt;
578
579 # Function examples in boolean context
580 &lt;If "md5('foo') == 'acbd18db4cc2f85cedef654fccc4a4d8'"&gt;
581   Header set checksum-matched true
582 &lt;/If&gt;
583 &lt;If "md5('foo') == replace('md5:XXXd18db4cc2f85cedef654fccc4a4d8', 'md5:XXX', 'acb')"&gt;
584   Header set checksum-matched-2 true
585 &lt;/If&gt;
586
587 # Function example in string context
588 Header set foo-checksum "expr=%{md5:foo}"
589
590 # This delays the evaluation of the condition clause compared to &lt;If&gt;
591 Header always set CustomHeader my-value "expr=%{REQUEST_URI} =~ m#^/special_path.php$#"
592
593         </highlight>
594 </section>
595
596 <section id="other">
597     <title>Other</title>
598
599     <table border="1" style="zebra">
600     <columnspec><column width=".2"/><column width=".2"/><column width=".6"/></columnspec>
601
602     <tr><th>Name</th><th>Alternative</th> <th>Description</th></tr>
603     <tr><td><code>-in</code></td>
604         <td><code>in</code></td>
605         <td>string contained in wordlist</td></tr>
606     <tr><td><code>/regexp/</code></td>
607         <td><code>m#regexp#</code></td>
608         <td>Regular expression (the second form allows different
609         delimiters than /)</td></tr>
610     <tr><td><code>/regexp/i</code></td>
611         <td><code>m#regexp#i</code></td>
612         <td>Case insensitive regular expression</td></tr>
613     <tr><td><code>$0 ... $9</code></td>
614         <td></td>
615         <td>Regular expression backreferences</td></tr>
616     </table>
617
618     <section id="rebackref">
619         <title>Regular expression backreferences</title>
620         <p>The strings <code>$0</code> ... <code>$9</code> allow to reference
621         the capture groups from a previously executed, successfully
622         matching regular expressions. They can normally only be used in the
623         same expression as the matching regex, but some modules allow special
624         uses.</p>
625     </section>
626
627 </section>
628
629 <section id="sslrequire">
630     <title>Comparison with SSLRequire</title>
631     <p>The <em>ap_expr</em> syntax is mostly a superset of the syntax of the
632     deprecated <directive module="mod_ssl">SSLRequire</directive> directive.
633     The differences are described in <directive
634     module="mod_ssl">SSLRequire</directive>'s documentation.</p>
635 </section>
636
637 <section id="compatibility">
638     <title>Version History</title>
639     <p>The <code>req_novary</code> <a href="#functions">function</a>
640     is available for versions 2.4.4 and later.</p>
641 </section>
642
643 </manualpage>