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