]> granicus.if.org Git - apache/blob - docs/manual/expr.html.en
Update transforms.
[apache] / docs / manual / expr.html.en
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
4         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5               This file is generated from xml source: DO NOT EDIT
6         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7       -->
8 <title>Expressions in Apache HTTP Server - Apache HTTP Server</title>
9 <link href="./style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10 <link href="./style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11 <link href="./style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="./style/css/prettify.css" />
12 <script src="./style/scripts/prettify.js" type="text/javascript">
13 </script>
14
15 <link href="./images/favicon.ico" rel="shortcut icon" /></head>
16 <body id="manual-page"><div id="page-header">
17 <p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p>
18 <p class="apache">Apache HTTP Server Version 2.5</p>
19 <img alt="" src="./images/feather.gif" /></div>
20 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="./images/left.gif" /></a></div>
21 <div id="path">
22 <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="./">Version 2.5</a></div><div id="page-content"><div id="preamble"><h1>Expressions in Apache HTTP Server</h1>
23 <div class="toplang">
24 <p><span>Available Languages: </span><a href="./en/expr.html" title="English">&nbsp;en&nbsp;</a> |
25 <a href="./fr/expr.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a></p>
26 </div>
27
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         <code class="directive"><a href="./mod/mod_ssl.html#sslrequire">SSLRequire</a></code> expressions can be
37         replaced by <a href="mod/mod_authz_core.html#reqexpr">Require expr</a>.
38     </p>
39   </div>
40 <div id="quickview"><ul id="toc"><li><img alt="" src="./images/down.gif" /> <a href="#grammar">Grammar in Backus-Naur Form notation</a></li>
41 <li><img alt="" src="./images/down.gif" /> <a href="#vars">Variables</a></li>
42 <li><img alt="" src="./images/down.gif" /> <a href="#binop">Binary operators</a></li>
43 <li><img alt="" src="./images/down.gif" /> <a href="#unnop">Unary operators</a></li>
44 <li><img alt="" src="./images/down.gif" /> <a href="#functions">Functions</a></li>
45 <li><img alt="" src="./images/down.gif" /> <a href="#examples">Example expressions</a></li>
46 <li><img alt="" src="./images/down.gif" /> <a href="#other">Other</a></li>
47 <li><img alt="" src="./images/down.gif" /> <a href="#sslrequire">Comparison with SSLRequire</a></li>
48 </ul><h3>See also</h3><ul class="seealso"><li><code class="directive"><a href="./mod/core.html#if">&lt;If&gt;</a></code></li><li><code class="directive"><a href="./mod/core.html#elseif">&lt;ElseIf&gt;</a></code></li><li><code class="directive"><a href="./mod/core.html#else">&lt;Else&gt;</a></code></li><li><code class="directive"><a href="./mod/mod_rewrite.html#rewritecond">RewriteCond</a></code></li><li><code class="directive"><a href="./mod/mod_setenvif.html#setenvifexpr">SetEnvIfExpr</a></code></li><li><code class="directive"><a href="./mod/mod_headers.html#header">Header</a></code></li><li><code class="directive"><a href="./mod/mod_headers.html#requestheader">RequestHeader</a></code></li><li><code class="directive"><a href="./mod/mod_filter.html#filterprovider">FilterProvider</a></code></li><li><a href="mod/mod_authz_core.html#reqexpr">Require expr</a></li><li><code class="directive"><a href="./mod/mod_ssl.html#sslrequire">SSLRequire</a></code></li><li><code class="directive"><a href="./mod/mod_log_debug.html#logmessage">LogMessage</a></code></li><li><code class="module"><a href="./mod/mod_include.html">mod_include</a></code></li></ul></div>
49 <div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
50 <div class="section">
51 <h2><a name="grammar" id="grammar">Grammar in Backus-Naur Form notation</a></h2>
52     
53       <p><a href="http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form">Backus-Naur Form</a> (BNF) is a notation
54       technique for context-free grammars, often used to describe the syntax of languages used in computing.
55       </p>
56 <blockquote>
57 <pre>
58 expr        ::= "<strong>true</strong>" | "<strong>false</strong>"
59               | "<strong>!</strong>" expr
60               | expr "<strong>&amp;&amp;</strong>" expr
61               | expr "<strong>||</strong>" expr
62               | "<strong>(</strong>" expr "<strong>)</strong>"
63               | comp
64
65 comp        ::= stringcomp
66               | integercomp
67               | unaryop word
68               | word binaryop word
69               | word "<strong>in</strong>" "<strong>{</strong>" wordlist "<strong>}</strong>"
70               | word "<strong>in</strong>" listfunction
71               | word "<strong>=~</strong>" regex
72               | word "<strong>!~</strong>" regex
73
74
75 stringcomp  ::= word "<strong>==</strong>" word
76               | word "<strong>!=</strong>" word
77               | word "<strong>&lt;</strong>"  word
78               | word "<strong>&lt;=</strong>" word
79               | word "<strong>&gt;</strong>"  word
80               | word "<strong>&gt;=</strong>" word
81
82 integercomp ::= word "<strong>-eq</strong>" word | word "<strong>eq</strong>" word
83               | word "<strong>-ne</strong>" word | word "<strong>ne</strong>" word
84               | word "<strong>-lt</strong>" word | word "<strong>lt</strong>" word
85               | word "<strong>-le</strong>" word | word "<strong>le</strong>" word
86               | word "<strong>-gt</strong>" word | word "<strong>gt</strong>" word
87               | word "<strong>-ge</strong>" word | word "<strong>ge</strong>" word
88
89 wordlist    ::= word
90               | wordlist "<strong>,</strong>" word
91
92 word        ::= word "<strong>.</strong>" word
93               | digit
94               | "<strong>'</strong>" string "<strong>'</strong>"
95               | "<strong>"</strong>" string "<strong>"</strong>"
96               | variable
97               | rebackref
98               | function
99
100 string      ::= stringpart
101               | string stringpart
102
103 stringpart  ::= cstring
104               | variable
105               | rebackref
106
107 cstring     ::= ...
108 digit       ::= [0-9]+
109
110 variable    ::= "<strong>%{</strong>" varname "<strong>}</strong>"
111               | "<strong>%{</strong>" funcname "<strong>:</strong>" funcargs "<strong>}</strong>"
112
113 rebackref   ::= "<strong>$</strong>" [0-9]
114
115 function     ::= funcname "<strong>(</strong>" word "<strong>)</strong>"
116
117 listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
118 </pre>
119 </blockquote>
120
121 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
122 <div class="section">
123 <h2><a name="vars" id="vars">Variables</a></h2>
124     
125
126     <p>The expression parser provides a number of variables of the form
127     <code>%{HTTP_HOST}</code>. Note that the value of a variable may depend
128     on the phase of the request processing in which it is evaluated.  For
129     example, an expression used in an <code class="directive">&lt;If &gt;</code>
130     directive is evaluated before authentication is done. Therefore,
131     <code>%{REMOTE_USER}</code> will not be set in this case.</p>
132
133     <p>The following variables provide the values of the named HTTP request
134     headers. The values of other headers can be obtained witht the
135     <code>req</code> <a href="#functions">function</a>.</p>
136
137     <table class="bordered"><tr class="header"><th>Name</th></tr>
138 <tr><td><code>HTTP_ACCEPT</code></td></tr>
139 <tr class="odd"><td><code>HTTP_FORWARDED</code></td></tr>
140 <tr><td><code>HTTP_HOST</code></td></tr>
141 <tr class="odd"><td><code>HTTP_PROXY_CONNECTION</code></td></tr>
142 <tr><td><code>HTTP_REFERER</code></td></tr>
143 <tr class="odd"><td><code>HTTP_USER_AGENT</code></td></tr>
144 </table>
145
146     <p>Other request related variables</p>
147
148     <table class="bordered"><tr class="header"><th>Name</th><th>Description</th></tr>
149 <tr><td><code>REQUEST_METHOD</code></td>
150         <td>The HTTP method of the incoming request (e.g.
151             <code>GET</code>)</td></tr>
152 <tr class="odd"><td><code>REQUEST_SCHEME</code></td>
153         <td>The scheme part of the request's URI</td></tr>
154 <tr><td><code>REQUEST_URI</code></td>
155         <td>The path part of the request's URI</td></tr>
156 <tr class="odd"><td><code>DOCUMENT_URI</code></td>
157         <td>Same as REQUEST_URI</td></tr>
158 <tr><td><code>REQUEST_FILENAME</code></td>
159         <td>The full local filesystem path to the file or script matching the
160             request, if this has already been determined by the server at the
161             time <code>REQUEST_FILENAME</code> is referenced. Otherwise, such
162             as when used in virtual host context, the same value as
163             <code>REQUEST_URI</code> </td></tr>
164 <tr class="odd"><td><code>SCRIPT_FILENAME</code></td>
165         <td>Same as <code>REQUEST_FILENAME</code></td></tr>
166 <tr><td><code>LAST_MODIFIED</code></td>
167         <td>The date and time of last modification of the file in the format
168             <code>20101231235959</code>, if this has already been determined by
169             the server at the time <code>LAST_MODIFIED</code> is referenced.
170             </td></tr>
171 <tr class="odd"><td><code>SCRIPT_USER</code></td>
172         <td>The user name of the owner of the script.</td></tr>
173 <tr><td><code>SCRIPT_GROUP</code></td>
174         <td>The group name of the group of the script.</td></tr>
175 <tr class="odd"><td><code>PATH_INFO</code></td>
176         <td>The trailing path name information, see
177             <code class="directive"><a href="./mod/core.html#acceptpathinfo">AcceptPathInfo</a></code></td></tr>
178 <tr><td><code>QUERY_STRING</code></td>
179         <td>The query string of the current request</td></tr>
180 <tr class="odd"><td><code>IS_SUBREQ</code></td>
181         <td>"<code>true</code>" if the current request is a subrequest,
182             "<code>false</code>" otherwise</td></tr>
183 <tr><td><code>THE_REQUEST</code></td>
184         <td>The complete request line (e.g.,
185             "<code>GET /index.html HTTP/1.1</code>")</td></tr>
186 <tr class="odd"><td><code>REMOTE_ADDR</code></td>
187         <td>The IP address of the remote host</td></tr>
188 <tr><td><code>REMOTE_HOST</code></td>
189         <td>The host name of the remote host</td></tr>
190 <tr class="odd"><td><code>REMOTE_USER</code></td>
191         <td>The name of the authenticated user (if any)</td></tr>
192 <tr><td><code>REMOTE_IDENT</code></td>
193         <td>The user name set by <code class="module"><a href="./mod/mod_ident.html">mod_ident</a></code></td></tr>
194 <tr class="odd"><td><code>SERVER_NAME</code></td>
195         <td>The <code class="directive"><a href="./mod/core.html#servername">ServerName</a></code> of
196             the current vhost</td></tr>
197 <tr><td><code>SERVER_PORT</code></td>
198         <td>The server port of the current vhost, see
199             <code class="directive"><a href="./mod/core.html#servername">ServerName</a></code></td></tr>
200 <tr class="odd"><td><code>SERVER_ADMIN</code></td>
201         <td>The <code class="directive"><a href="./mod/core.html#serveradmin">ServerAdmin</a></code> of
202             the current vhost</td></tr>
203 <tr><td><code>SERVER_PROTOCOL</code></td>
204         <td>The protocol used by the request</td></tr>
205 <tr class="odd"><td><code>DOCUMENT_ROOT</code></td>
206         <td>The <code class="directive"><a href="./mod/core.html#documentroot">DocumentRoot</a></code> of
207             the current vhost</td></tr>
208 <tr><td><code>AUTH_TYPE</code></td>
209         <td>The configured <code class="directive"><a href="./mod/mod_authn_core.html#authtype">AuthType</a></code>
210             (e.g. "<code>basic</code>")</td></tr>
211 <tr class="odd"><td><code>CONTENT_TYPE</code></td>
212         <td>The content type of the response</td></tr>
213 <tr><td><code>HANDLER</code></td>
214         <td>The name of the <a href="handler.html">handler</a> creating
215             the response</td></tr>
216 <tr class="odd"><td><code>HTTPS</code></td>
217         <td>"<code>on</code>" if the request uses https,
218             "<code>off</code>" otherwise</td></tr>
219 <tr><td><code>IPV6</code></td>
220         <td>"<code>on</code>" if the connection uses IPv6,
221             "<code>off</code>" otherwise</td></tr>
222 <tr class="odd"><td><code>REQUEST_STATUS</code></td>
223         <td>The HTTP error status of the request</td></tr>
224 <tr><td><code>REQUEST_LOG_ID</code></td>
225         <td>The error log id of the request (see
226             <code class="directive"><a href="./mod/core.html#errorlogformat">ErrorLogFormat</a></code>)</td></tr>
227 <tr class="odd"><td><code>CONN_LOG_ID</code></td>
228         <td>The error log id of the connection (see
229             <code class="directive"><a href="./mod/core.html#errorlogformat">ErrorLogFormat</a></code>)</td></tr>
230 <tr><td><code>CONN_REMOTE_ADDR</code></td>
231         <td>The peer IP address of the connection (see the
232             <code class="module"><a href="./mod/mod_remoteip.html">mod_remoteip</a></code> module)</td></tr>
233 </table>
234
235     <p>Misc variables</p>
236
237     <table class="bordered"><tr class="header"><th>Name</th><th>Description</th></tr>
238 <tr><td><code>TIME_YEAR</code></td>
239         <td>The current year (e.g. <code>2010</code>)</td></tr>
240 <tr class="odd"><td><code>TIME_MON</code></td>
241         <td>The current month (<code>1</code>, ..., <code>12</code>)</td></tr>
242 <tr><td><code>TIME_DAY</code></td>
243         <td>The current day of the month</td></tr>
244 <tr class="odd"><td><code>TIME_HOUR</code></td>
245         <td>The hour part of the current time
246             (<code>0</code>, ..., <code>23</code>)</td></tr>
247 <tr><td><code>TIME_MIN</code></td>
248         <td>The minute part of the current time </td></tr>
249 <tr class="odd"><td><code>TIME_SEC</code></td>
250         <td>The second part of the current time </td></tr>
251 <tr><td><code>TIME_WDAY</code></td>
252         <td>The day of the week (starting with <code>0</code>
253             for Sunday)</td></tr>
254 <tr class="odd"><td><code>TIME</code></td>
255         <td>The date and time in the format <code>20101231235959</code></td></tr>
256 <tr><td><code>SERVER_SOFTWARE</code></td>
257         <td>The server version string</td></tr>
258 <tr class="odd"><td><code>API_VERSION</code></td>
259         <td>The date of the API version (module magic number)</td></tr>
260 </table>
261
262     <p>Some modules register additional variables, see e.g. <code class="module"><a href="./mod/mod_ssl.html">mod_ssl</a></code>.</p>
263
264 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
265 <div class="section">
266 <h2><a name="binop" id="binop">Binary operators</a></h2>
267     
268
269     <p>With the exception of some built-in comparison operators, binary
270     operators have the form "<code>-[a-zA-Z][a-zA-Z0-9_]+</code>", i.e. a
271     minus and at least two characters. The name is not case sensitive.
272     Modules may register additional binary operators.</p>
273
274     <h3><a name="comp" id="comp">Comparison operators</a></h3>
275     
276
277     <table class="bordered"><tr class="header"><th>Name</th><th>Alternative</th> <th>Description</th></tr>
278 <tr><td><code>==</code></td>
279         <td><code>=</code></td>
280         <td>String equality</td></tr>
281 <tr class="odd"><td><code>!=</code></td>
282         <td />
283         <td>String inequality</td></tr>
284 <tr><td><code>&lt;</code></td>
285         <td />
286         <td>String less than</td></tr>
287 <tr class="odd"><td><code>&lt;=</code></td>
288         <td />
289         <td>String less than or equal</td></tr>
290 <tr><td><code>&gt;</code></td>
291         <td />
292         <td>String greater than</td></tr>
293 <tr class="odd"><td><code>&gt;=</code></td>
294         <td />
295         <td>String greater than or equal</td></tr>
296 <tr><td><code>-eq</code></td>
297         <td><code>eq</code></td>
298         <td>Integer equality</td></tr>
299 <tr class="odd"><td><code>-ne</code></td>
300         <td><code>ne</code></td>
301         <td>Integer inequality</td></tr>
302 <tr><td><code>-lt</code></td>
303         <td><code>lt</code></td>
304         <td>Integer less than</td></tr>
305 <tr class="odd"><td><code>-le</code></td>
306         <td><code>le</code></td>
307         <td>Integer less than or equal</td></tr>
308 <tr><td><code>-gt</code></td>
309         <td><code>gt</code></td>
310         <td>Integer greater than</td></tr>
311 <tr class="odd"><td><code>-ge</code></td>
312         <td><code>ge</code></td>
313         <td>Integer greater than or equal</td></tr>
314 </table>
315     
316
317     <h3><a name="binaryother" id="binaryother">Other binary operators</a></h3>
318     
319
320     <table class="bordered"><tr class="header"><th>Name</th><th>Description</th></tr>
321 <tr><td><code>-ipmatch</code></td>
322         <td>IP address matches address/netmask</td></tr>
323 <tr class="odd"><td><code>-strmatch</code></td>
324         <td>left string matches pattern given by right string (containing
325             wildcards *, ?, [])</td></tr>
326 <tr><td><code>-strcmatch</code></td>
327         <td>same as <code>-strmatch</code>, but case insensitive</td></tr>
328 <tr class="odd"><td><code>-fnmatch</code></td>
329         <td>same as <code>-strmatch</code>, but slashes are not matched by
330             wildcards</td></tr>
331 </table>
332     
333
334 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
335 <div class="section">
336 <h2><a name="unnop" id="unnop">Unary operators</a></h2>
337     
338
339     <p>Unary operators take one argument and have the form
340     "<code>-[a-zA-Z]</code>", i.e. a minus and one character.
341     The name <em>is</em> case sensitive.
342     Modules may register additional unary operators.</p>
343
344     <table class="bordered"><tr class="header"><th>Name</th><th>Description</th><th>Restricted</th></tr>
345 <tr><td><code>-d</code></td>
346         <td>The argument is treated as a filename.
347             True if the file exists and is a directory</td><td>yes</td></tr>
348 <tr class="odd"><td><code>-e</code></td>
349         <td>The argument is treated as a filename.
350             True if the file (or dir or special) exists</td><td>yes</td></tr>
351 <tr><td><code>-f</code></td>
352         <td>The argument is treated as a filename.
353             True if the file exists and is regular file</td><td>yes</td></tr>
354 <tr class="odd"><td><code>-s</code></td>
355         <td>The argument is treated as a filename.
356             True if the file exists and is not empty</td><td>yes</td></tr>
357 <tr><td><code>-L</code></td>
358         <td>The argument is treated as a filename.
359             True if the file exists and is symlink</td><td>yes</td></tr>
360 <tr class="odd"><td><code>-h</code></td>
361         <td>The argument is treated as a filename.
362             True if the file exists and is symlink
363             (same as <code>-L</code>)</td><td>yes</td></tr>
364 <tr><td><code>-F</code></td>
365         <td>True if string is a valid file, accessible via all the server's
366             currently-configured access controls for that path. This uses an
367             internal subrequest to do the check, so use it with care - it can
368             impact your server's performance!</td><td /></tr>
369 <tr class="odd"><td><code>-U</code></td>
370         <td>True if string is a valid URL, accessible via all the server's
371             currently-configured access controls for that path. This uses an
372             internal subrequest to do the check, so use it with care - it can
373             impact your server's performance!</td><td /></tr>
374 <tr><td><code>-A</code></td>
375         <td>Alias for <code>-U</code></td><td /></tr>
376 <tr class="odd"><td><code>-n</code></td>
377         <td>True if string is not empty</td><td /></tr>
378 <tr><td><code>-z</code></td>
379         <td>True if string is empty</td><td /></tr>
380 <tr class="odd"><td><code>-T</code></td>
381         <td>False if string is empty, "<code>0</code>", "<code>off</code>",
382             "<code>false</code>", or "<code>no</code>" (case insensitive).
383             True otherwise.</td><td /></tr>
384 <tr><td><code>-R</code></td>
385         <td>Same as "<code>%{REMOTE_ADDR} -ipmatch ...</code>", but more efficient
386         </td><td /></tr>
387 </table>
388
389     <p>The operators marked as "restricted" are not available in some modules
390     like <code class="module"><a href="./mod/mod_include.html">mod_include</a></code>.</p>
391 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
392 <div class="section">
393 <h2><a name="functions" id="functions">Functions</a></h2>
394     
395
396     <p>Normal string-valued functions take one string as argument and return
397     a string. Functions names are not case sensitive.
398     Modules may register additional functions.</p>
399
400     <table class="bordered"><tr class="header"><th>Name</th><th>Description</th><th>Restricted</th></tr>
401 <tr><td><code>req</code>, <code>http</code></td>
402         <td>Get HTTP request header</td><td /></tr>
403 <tr class="odd"><td><code>resp</code></td>
404         <td>Get HTTP response header</td><td /></tr>
405 <tr><td><code>reqenv</code></td>
406         <td>Lookup request environment variable</td><td /></tr>
407 <tr class="odd"><td><code>osenv</code></td>
408         <td>Lookup operating system environment variable</td><td /></tr>
409 <tr><td><code>note</code></td>
410         <td>Lookup request note</td><td /></tr>
411 <tr class="odd"><td><code>env</code></td>
412         <td>Return first match of <code>note</code>, <code>reqenv</code>,
413             <code>osenv</code></td><td /></tr>
414 <tr><td><code>tolower</code></td>
415         <td>Convert string to lower case</td><td /></tr>
416 <tr class="odd"><td><code>toupper</code></td>
417         <td>Convert string to uppser case</td><td /></tr>
418 <tr><td><code>escape</code></td>
419         <td>Escape special characters in %hex encoding</td><td /></tr>
420 <tr class="odd"><td><code>unescape</code></td>
421         <td>Unescape %hex encoded string, leaving encoded slashes alone;
422             return empty string if %00 is found</td><td /></tr>
423 <tr><td><code>file</code></td>
424         <td>Read contents from a file</td><td>yes</td></tr>
425 <tr class="odd"><td><code>filesize</code></td>
426         <td>Return size of a file (or 0 if file does not exist or is not
427             regular file)</td><td>yes</td></tr>
428 </table>
429
430     <p>The functions marked as "restricted" are not available in some modules
431     like <code class="module"><a href="./mod/mod_include.html">mod_include</a></code>.</p>
432
433     <p>In addition to string-valued functions, there are also list-valued functions which
434     take one string as argument and return a wordlist, i.e. a list of strings. The wordlist
435     can be used with the special <code>-in</code> operator.
436     Functions names are not case sensitive.
437     Modules may register additional functions.</p>
438
439     <p>There are no built-in list-valued functions. <code class="module"><a href="./mod/mod_ssl.html">mod_ssl</a></code>
440     provides <code>PeerExtList</code>.  See the description of
441     <code class="directive"><a href="./mod/mod_ssl.html#sslrequire">SSLRequire</a></code> for details
442     (but <code>PeerExtList</code> is also usable outside
443     of <code class="directive"><a href="./mod/mod_ssl.html#sslrequire">SSLRequire</a></code>).</p>
444
445 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
446 <div class="section">
447 <h2><a name="examples" id="examples">Example expressions</a></h2>
448     
449         
450         <p>The following examples show how expressions might be used to evaluate requests:</p>
451         
452         <div class="example"><p><code>
453         # Compare the host name to example.com and redirect to www.example.com if it matches<br />
454         &lt;If "%{HTTP_HOST} == 'example.com'"&gt;<br />
455         <span class="indent">
456                 Redirect permanent / http://www.example.com<br />
457         </span>
458         &lt;/If&gt;<br /><br />
459         # Force text/plain if requesting a file with the query string contains 'forcetext'<br />
460         &lt;If "%{QUERY_STRING} =~ /forcetext/"&gt;<br />
461         <span class="indent">
462                 ForceType text/plain<br />
463         </span>
464         &lt;/If&gt;<br /><br />
465         # Only allow access to this content during business hours<br />
466         &lt;Directory "/foo/bar/business"&gt;<br />
467         <span class="indent">
468                 Require expr %{TIME_HOUR} &gt;= 9 &amp;&amp; %{TIME_HOUR} &lt;= 17 <br />
469         </span>
470         &lt;/Directory&gt;      
471         </code></p></div>
472 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
473 <div class="section">
474 <h2><a name="other" id="other">Other</a></h2>
475     
476
477     <table class="bordered"><tr class="header"><th>Name</th><th>Alternative</th> <th>Description</th></tr>
478 <tr><td><code>-in</code></td>
479         <td><code>in</code></td>
480         <td>string contained in string list</td></tr>
481 <tr class="odd"><td><code>/regexp/</code></td>
482         <td><code>m#regexp#</code></td>
483         <td>Regular expression (the second form allows different delimiters than /)</td></tr>
484 <tr><td><code>/regexp/i</code></td>
485         <td><code>m#regexp#i</code></td>
486         <td>Case insensitive regular expression</td></tr>
487 <tr class="odd"><td><code>$0 ... $9</code></td>
488         <td />
489         <td>Regular expression backreferences</td></tr>
490 </table>
491
492     <h3><a name="rebackref" id="rebackref">Regular expression backreferences</a></h3>
493         
494         <p>The strings <code>$0</code> ... <code>$9</code> allow to reference
495         the capture groups from a previously executed, successfully
496         matching regular expressions. They can normally only be used in the
497         same expression as the matching regex, but some modules allow special
498         uses.</p>
499     
500
501 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
502 <div class="section">
503 <h2><a name="sslrequire" id="sslrequire">Comparison with SSLRequire</a></h2>
504     
505     <p>The <em>ap_expr</em> syntax is mostly a superset of the syntax of the
506     deprecated <code class="directive"><a href="./mod/mod_ssl.html#sslrequire">SSLRequire</a></code> directive.
507     The differences are described in <code class="directive"><a href="./mod/mod_ssl.html#sslrequire">SSLRequire</a></code>'s documentation.</p>
508 </div></div>
509 <div class="bottomlang">
510 <p><span>Available Languages: </span><a href="./en/expr.html" title="English">&nbsp;en&nbsp;</a> |
511 <a href="./fr/expr.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a></p>
512 </div><div id="footer">
513 <p class="apache">Copyright 2012 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
514 <p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p></div><script type="text/javascript">
515     if (typeof(prettyPrint) !== undefined) {
516         prettyPrint();
517     }
518 </script>
519 </body></html>