]> granicus.if.org Git - apache/blob - docs/manual/expr.html.en
Crosslinking mod_ssl.html and expr.html
[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" />
12 <link href="./images/favicon.ico" rel="shortcut icon" /></head>
13 <body id="manual-page"><div id="page-header">
14 <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>
15 <p class="apache">Apache HTTP Server Version 2.3</p>
16 <img alt="" src="./images/feather.gif" /></div>
17 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="./images/left.gif" /></a></div>
18 <div id="path">
19 <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.3</a></div><div id="page-content"><div id="preamble"><h1>Expressions in Apache HTTP Server</h1>
20 <div class="toplang">
21 <p><span>Available Languages: </span><a href="./en/expr.html" title="English">&nbsp;en&nbsp;</a></p>
22 </div>
23
24     <p>Historically, there are several syntax variants for expressions used to express
25         a condition in the different modules of the Apache HTTP Server.
26         There is some ongoing effort to only use a single variant, called <em>ap_expr</em>,
27         for all configuration directives.
28         This document describes the <em>ap_expr</em> expression parser.
29     </p>
30   </div>
31 <div id="quickview"><ul id="toc"><li><img alt="" src="./images/down.gif" /> <a href="#grammar">Grammar in BNF notation</a></li>
32 <li><img alt="" src="./images/down.gif" /> <a href="#vars">Variables</a></li>
33 <li><img alt="" src="./images/down.gif" /> <a href="#binop">Binary operators</a></li>
34 <li><img alt="" src="./images/down.gif" /> <a href="#unnop">Unary operators</a></li>
35 <li><img alt="" src="./images/down.gif" /> <a href="#functions">Functions</a></li>
36 </ul></div>
37 <div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
38 <div class="section">
39 <h2><a name="grammar" id="grammar">Grammar in BNF notation</a></h2>
40     
41 <blockquote>
42 <pre>
43 expr        ::= "<strong>true</strong>" | "<strong>false</strong>"
44               | "<strong>!</strong>" expr
45               | expr "<strong>&amp;&amp;</strong>" expr
46               | expr "<strong>||</strong>" expr
47               | "<strong>(</strong>" expr "<strong>)</strong>"
48               | comp
49
50 comp        ::= stringcomp
51               | integercomp
52               | unaryop word
53               | word binaryop word
54               | word "<strong>in</strong>" "<strong>{</strong>" wordlist "<strong>}</strong>"
55               | word "<strong>in</strong>" listfunction
56               | word "<strong>=~</strong>" regex
57               | word "<strong>!~</strong>" regex
58
59
60 stringcomp  ::= word "<strong>==</strong>" word | word "<strong>eq</strong>" word
61               | word "<strong>!=</strong>" word | word "<strong>ne</strong>" word
62               | word "<strong>&lt;</strong>"  word | word "<strong>lt</strong>" word
63               | word "<strong>&lt;=</strong>" word | word "<strong>le</strong>" word
64               | word "<strong>&gt;</strong>"  word | word "<strong>gt</strong>" word
65               | word "<strong>&gt;=</strong>" word | word "<strong>ge</strong>" word
66
67 integercomp ::= word "<strong>-eq</strong>" word | word "<strong>eq</strong>" word
68               | word "<strong>-ne</strong>" word | word "<strong>ne</strong>" word
69               | word "<strong>-lt</strong>" word | word "<strong>lt</strong>" word
70               | word "<strong>-le</strong>" word | word "<strong>le</strong>" word
71               | word "<strong>-gt</strong>" word | word "<strong>gt</strong>" word
72               | word "<strong>-ge</strong>" word | word "<strong>ge</strong>" word
73
74 wordlist    ::= word
75               | wordlist "<strong>,</strong>" word
76
77 word        ::= word "<strong>.</strong>" word
78               | digit
79               | "<strong>'</strong>" string "<strong>'</strong>"
80               | "<strong>"</strong>" string "<strong>"</strong>"
81               | variable
82               | function
83
84 string      ::= stringpart
85               | string stringpart
86
87 stringpart  ::= cstring
88               | variable
89
90 cstring     ::= ...
91 digit       ::= [0-9]+
92
93 variable    ::= "<strong>%{</strong>" varname "<strong>}</strong>"
94               | "<strong>%{</strong>" funcname "<strong>:</strong>" funcargs "<strong>}</strong>"
95
96 function     ::= funcname "<strong>(</strong>" word "<strong>)</strong>"
97
98 listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
99 </pre>
100 </blockquote>
101
102 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
103 <div class="section">
104 <h2><a name="vars" id="vars">Variables</a></h2>
105     
106 <p>XXX: not all vars are available in all request phases</p>
107     
108     <p>Request headers (XXX:see req function)</p>
109
110     <table class="bordered"><tr class="header"><th>Name</th></tr>
111 <tr><td><code>HTTP_ACCEPT</code></td></tr>
112 <tr class="odd"><td><code>HTTP_FORWARDED</code></td></tr>
113 <tr><td><code>HTTP_HOST</code></td></tr>
114 <tr class="odd"><td><code>HTTP_PROXY_CONNECTION</code></td></tr>
115 <tr><td><code>HTTP_REFERER</code></td></tr>
116 <tr class="odd"><td><code>HTTP_USER_AGENT</code></td></tr>
117 </table>
118
119     <p>Other request related variables</p>
120
121     <table class="bordered"><tr class="header"><th>Name</th><th>Description</th></tr>
122 <tr><td><code>REQUEST_METHOD</code></td>
123         <td /></tr>
124 <tr class="odd"><td><code>REQUEST_SCHEME</code></td>
125         <td /></tr>
126 <tr><td><code>REQUEST_URI</code></td>
127         <td /></tr>
128 <tr class="odd"><td><code>REQUEST_FILENAME</code></td>
129         <td /></tr>
130 <tr><td><code>REMOTE_HOST</code></td>
131         <td /></tr>
132 <tr class="odd"><td><code>REMOTE_IDENT</code></td>
133         <td /></tr>
134 <tr><td><code>REMOTE_USER</code></td>
135         <td /></tr>
136 <tr class="odd"><td><code>SERVER_ADMIN</code></td>
137         <td /></tr>
138 <tr><td><code>SERVER_NAME</code></td>
139         <td /></tr>
140 <tr class="odd"><td><code>SERVER_PORT</code></td>
141         <td /></tr>
142 <tr><td><code>SERVER_PROTOCOL</code></td>
143         <td /></tr>
144 <tr class="odd"><td><code>SCRIPT_FILENAME</code></td>
145         <td /></tr>
146 <tr><td><code>PATH_INFO</code></td>
147         <td /></tr>
148 <tr class="odd"><td><code>QUERY_STRING</code></td>
149         <td /></tr>
150 <tr><td><code>IS_SUBREQ</code></td>
151         <td /></tr>
152 <tr class="odd"><td><code>DOCUMENT_ROOT</code></td>
153         <td /></tr>
154 <tr><td><code>AUTH_TYPE</code></td>
155         <td /></tr>
156 <tr class="odd"><td><code>THE_REQUEST</code></td>
157         <td /></tr>
158 <tr><td><code>CONTENT_TYPE</code></td>
159         <td /></tr>
160 <tr class="odd"><td><code>HANDLER</code></td>
161         <td /></tr>
162 <tr><td><code>REMOTE_ADDR</code></td>
163         <td /></tr>
164 <tr class="odd"><td><code>HTTPS</code></td>
165         <td /></tr>
166 <tr><td><code>IPV6</code></td>
167         <td /></tr>
168 <tr class="odd"><td><code>REQUEST_LOG_ID</code></td>
169         <td /></tr>
170 <tr><td><code>CONN_LOG_ID</code></td>
171         <td /></tr>
172 </table>
173
174     <p>Misc variables</p>
175
176     <table class="bordered"><tr class="header"><th>Name</th><th>Description</th></tr>
177 <tr><td><code>TIME_YEAR</code></td>
178         <td /></tr>
179 <tr class="odd"><td><code>TIME_MON</code></td>
180         <td /></tr>
181 <tr><td><code>TIME_DAY</code></td>
182         <td /></tr>
183 <tr class="odd"><td><code>TIME_HOUR</code></td>
184         <td /></tr>
185 <tr><td><code>TIME_MIN</code></td>
186         <td /></tr>
187 <tr class="odd"><td><code>TIME_SEC</code></td>
188         <td /></tr>
189 <tr><td><code>TIME_WDAY</code></td>
190         <td /></tr>
191 <tr class="odd"><td><code>TIME</code></td>
192         <td /></tr>
193 <tr><td><code>SERVER_SOFTWARE</code></td>
194         <td /></tr>
195 <tr class="odd"><td><code>API_VERSION</code></td>
196         <td /></tr>
197 </table>
198
199 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
200 <div class="section">
201 <h2><a name="binop" id="binop">Binary operators</a></h2>
202     
203
204     <p>With the exception of some built-in comparison operators, binary
205     operators have the form "<code>-[a-zA-Z][a-zA-Z0-9_]+</code>", i.e. a
206     minus and at least two characters. The name is not case sensitive.
207     Modules may register additional binary operators.</p>
208
209     <table class="bordered"><tr class="header"><th>Name</th><th>Alternative</th> <th>Description</th></tr>
210 <tr><td><code>==</code></td>
211         <td><code>=</code></td>
212         <td>String equality</td></tr>
213 <tr class="odd"><td><code>!=</code></td>
214         <td />
215         <td>String inequality</td></tr>
216 <tr><td><code>&lt;</code></td>
217         <td />
218         <td>String less than</td></tr>
219 <tr class="odd"><td><code>&lt;=</code></td>
220         <td />
221         <td>String less than or equal</td></tr>
222 <tr><td><code>&gt;</code></td>
223         <td />
224         <td>String greater than</td></tr>
225 <tr class="odd"><td><code>&gt;=</code></td>
226         <td />
227         <td>String greater than or equal</td></tr>
228 <tr><td><code>-eq</code></td>
229         <td><code>eq</code></td>
230         <td>Integer equality</td></tr>
231 <tr class="odd"><td><code>-ne</code></td>
232         <td><code>ne</code></td>
233         <td>Integer inequality</td></tr>
234 <tr><td><code>-lt</code></td>
235         <td><code>lt</code></td>
236         <td>Integer less than</td></tr>
237 <tr class="odd"><td><code>-le</code></td>
238         <td><code>le</code></td>
239         <td>Integer less than or equal</td></tr>
240 <tr><td><code>-gt</code></td>
241         <td><code>gt</code></td>
242         <td>Integer greater than</td></tr>
243 <tr class="odd"><td><code>-ge</code></td>
244         <td><code>ge</code></td>
245         <td>Integer greater than or equal</td></tr>
246 </table>
247
248 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
249 <div class="section">
250 <h2><a name="unnop" id="unnop">Unary operators</a></h2>
251     
252
253     <p>Unary operators have the form "<code>-[a-zA-Z]</code>", i.e. a
254     minus and one character. The name <em>is</em> case sensitive.
255     Modules may register additional unary operators.</p>
256
257     <table class="bordered"><tr class="header"><th>Name</th><th>Description</th></tr>
258 <tr><td><code>-n</code></td>
259         <td>String is not empty</td></tr>
260 <tr class="odd"><td><code>-z</code></td>
261         <td>String is empty</td></tr>
262 </table>
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="functions" id="functions">Functions</a></h2>
267     
268
269     <p>Normal string-valued functions take one string as argument and return
270     a string. Functions names are not case sensitive.
271     Modules may register additional functions.</p>
272
273     <table class="bordered"><tr class="header"><th>Name</th><th>Description</th></tr>
274 <tr><td><code>req</code>, <code>http</code></td>
275         <td>Get HTTP request header</td></tr>
276 <tr class="odd"><td><code>resp</code></td>
277         <td>Get HTTP response header</td></tr>
278 <tr><td><code>reqenv</code></td>
279         <td>Lookup request environment variable</td></tr>
280 <tr class="odd"><td><code>osenv</code></td>
281         <td>Lookup operating system environment variable</td></tr>
282 <tr><td><code>note</code></td>
283         <td>Lookup request environment variable</td></tr>
284 <tr class="odd"><td><code>env</code></td>
285         <td>Return first match of <code>note</code>, <code>reqenv</code>,
286             <code>osenv</code></td></tr>
287 <tr><td><code>tolower</code></td>
288         <td>Convert string to lower case</td></tr>
289 <tr class="odd"><td><code>toupper</code></td>
290         <td>Convert string to uppser case</td></tr>
291 <tr><td><code>escape</code></td>
292         <td>Escape special characters in %hex encoding</td></tr>
293 <tr class="odd"><td><code>unescape</code></td>
294         <td>Unescape %hex encoded string, leaving URL-special characters encoded (XXX: describe better)</td></tr>
295 <tr><td><code>file</code></td>
296         <td>Read contents from a file</td></tr>
297 </table>
298
299     <p>In addition to string-valued functions, there are also list-valued functions which
300     take one string as argument and return a wordlist, i.e. a list of strings. The wordlist
301     can be used with the special <code>-in</code> operator.
302     Functions names are not case sensitive.
303     Modules may register additional functions.</p>
304
305     <p>There are no built-in list-valued functions. <code class="module"><a href="./mod/mod_ssl.html">mod_ssl</a></code>'s
306     <code class="directive"><a href="./mod/mod_ssl.html#sslrequire">SSLRequire</a></code> provides
307     <code>PeerExtList</code>.</p>
308
309 </div></div>
310 <div class="bottomlang">
311 <p><span>Available Languages: </span><a href="./en/expr.html" title="English">&nbsp;en&nbsp;</a></p>
312 </div><div id="footer">
313 <p class="apache">Copyright 2010 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>
314 <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>
315 </body></html>