expr.html.en revision c11bfe6804eff2f4c7054cf2f7b06f0c8b32e596
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<?xml version="1.0" encoding="ISO-8859-1"?>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd This file is generated from xml source: DO NOT EDIT
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd -->
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<title>Expressions in Apache HTTP Server - Apache HTTP Server</title>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen<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" />
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen<script src="/style/scripts/prettify.js" type="text/javascript">
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen</script>
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<link href="/images/favicon.ico" rel="shortcut icon" /></head>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<body id="manual-page"><div id="page-header">
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p>
3f08db06526d6901aa08c110b5bc7dde6bc39905nd<p class="apache">Apache HTTP Server Version 2.5</p>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<img alt="" src="/images/feather.gif" /></div>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="/images/left.gif" /></a></div>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<div id="path">
3f08db06526d6901aa08c110b5bc7dde6bc39905nd<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>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<div class="toplang">
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd<p><span>Available Languages: </span><a href="/en/expr.html" title="English">&nbsp;en&nbsp;</a> |
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd<a href="/fr/expr.html" hreflang="fr" rel="alternate" title="Fran�ais">&nbsp;fr&nbsp;</a></p>
ecc5150d35c0dc5ee5119c2717e6660fa331abbftakashi</div>
bc9d4698fce0238d2f6f2682e99423ebb1149976rbowen
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd <p>Historically, there are several syntax variants for expressions used to express
63f06dce77bb2d9b1c5aa5deeb47a1069987fd1end a condition in the different modules of the Apache HTTP Server.
d474d8ef01ec5c2a09341cd148851ed383c3287crbowen There is some ongoing effort to only use a single variant, called <em>ap_expr</em>,
d474d8ef01ec5c2a09341cd148851ed383c3287crbowen for all configuration directives.
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd This document describes the <em>ap_expr</em> expression parser.
4b575a6b6704b516f22d65a3ad35696d7b9ba372rpluem </p>
4b575a6b6704b516f22d65a3ad35696d7b9ba372rpluem <p>The <em>ap_expr</em> expression is intended to replace most other
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd expression variants in HTTPD. For example, the deprecated
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd <code class="directive"><a href="/mod/mod_ssl.html#sslrequire">SSLRequire</a></code> expressions can be
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd replaced by <a href="mod/mod_authz_core.html#reqexpr">Require expr</a>.
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd </p>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd </div>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<div id="quickview"><ul id="toc"><li><img alt="" src="/images/down.gif" /> <a href="#grammar">Grammar in Backus-Naur Form notation</a></li>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<li><img alt="" src="/images/down.gif" /> <a href="#vars">Variables</a></li>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<li><img alt="" src="/images/down.gif" /> <a href="#binop">Binary operators</a></li>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<li><img alt="" src="/images/down.gif" /> <a href="#unnop">Unary operators</a></li>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<li><img alt="" src="/images/down.gif" /> <a href="#functions">Functions</a></li>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<li><img alt="" src="/images/down.gif" /> <a href="#examples">Example expressions</a></li>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<li><img alt="" src="/images/down.gif" /> <a href="#other">Other</a></li>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<li><img alt="" src="/images/down.gif" /> <a href="#sslrequire">Comparison with SSLRequire</a></li>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd</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><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<div class="section">
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<h2><a name="grammar" id="grammar">Grammar in Backus-Naur Form notation</a></h2>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd <p><a href="http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form">Backus-Naur Form</a> (BNF) is a notation
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd technique for context-free grammars, often used to describe the syntax of languages used in computing.
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd In most cases, expressions are used to express boolean values.
80eed96ee3d8cfa0b66d9fb1cfe63fd83254d38bnilgun For these, the starting boint in the BNF is <code>expr</code>. However, a few directives
80eed96ee3d8cfa0b66d9fb1cfe63fd83254d38bnilgun like <code class="directive"><a href="/mod/mod_log_debug.html#logmessage">LogMessage</a></code> accept expressions
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd that evaluate to a string value. For those, the starting boint in the BNF is <code>code</code>.
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd </p>
316f02e3836836c82e19019ff23f90a7ebc65289nilgun<blockquote>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<pre>
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndexpr ::= "<strong>true</strong>" | "<strong>false</strong>"
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd | "<strong>!</strong>" expr
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd | expr "<strong>&amp;&amp;</strong>" expr
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd | expr "<strong>||</strong>" expr
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd | "<strong>(</strong>" expr "<strong>)</strong>"
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd | comp
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd
b43f840409794ed298e8634f6284741f193b6c4ftakashicomp ::= stringcomp
22d5d84393d960a2027f472036f3fee15d7dbce9nd | integercomp
22d5d84393d960a2027f472036f3fee15d7dbce9nd | unaryop word
22d5d84393d960a2027f472036f3fee15d7dbce9nd | word binaryop word
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd | word "<strong>in</strong>" "<strong>{</strong>" wordlist "<strong>}</strong>"
a78048ccbdb6256da15e6b0e7e95355e480c2301nd | word "<strong>in</strong>" listfunction
a78048ccbdb6256da15e6b0e7e95355e480c2301nd | word "<strong>=~</strong>" regex
50c04f297d76a57ead2fa6b73845f7563b1fc788sf | word "<strong>!~</strong>" regex
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd
a78048ccbdb6256da15e6b0e7e95355e480c2301ndstringcomp ::= word "<strong>==</strong>" word
623eebe956d9c2d6d073ed3eae855b56030b40e9noodl | word "<strong>!=</strong>" word
a78048ccbdb6256da15e6b0e7e95355e480c2301nd | word "<strong>&lt;</strong>" word
a78048ccbdb6256da15e6b0e7e95355e480c2301nd | word "<strong>&lt;=</strong>" word
ffb88a4885747797937e30a5ac8b1606da3cb4adnd | word "<strong>&gt;</strong>" word
909ce17e2bd0faef7b1c294f2307f009793fd493nd | word "<strong>&gt;=</strong>" word
a78048ccbdb6256da15e6b0e7e95355e480c2301nd
a78048ccbdb6256da15e6b0e7e95355e480c2301ndintegercomp ::= word "<strong>-eq</strong>" word | word "<strong>eq</strong>" word
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe | word "<strong>-ne</strong>" word | word "<strong>ne</strong>" word
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe | word "<strong>-lt</strong>" word | word "<strong>lt</strong>" word
42af92a661a06b3cebc88d585aad75064a309d51nd | word "<strong>-le</strong>" word | word "<strong>le</strong>" word
42af92a661a06b3cebc88d585aad75064a309d51nd | word "<strong>-gt</strong>" word | word "<strong>gt</strong>" word
ffb88a4885747797937e30a5ac8b1606da3cb4adnd | word "<strong>-ge</strong>" word | word "<strong>ge</strong>" word
6fe26506780e73be2a412d758af77fafdf03291and
a78048ccbdb6256da15e6b0e7e95355e480c2301ndwordlist ::= word
a78048ccbdb6256da15e6b0e7e95355e480c2301nd | wordlist "<strong>,</strong>" word
9649d29bb7801e0698e6a845e1a8a61534df58b3noodl
9649d29bb7801e0698e6a845e1a8a61534df58b3noodlword ::= word "<strong>.</strong>" word
a78048ccbdb6256da15e6b0e7e95355e480c2301nd | digit
a78048ccbdb6256da15e6b0e7e95355e480c2301nd | "<strong>'</strong>" string "<strong>'</strong>"
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd | "<strong>"</strong>" string "<strong>"</strong>"
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd | variable
08cf4a15275e4cb65a424b3a1db5410bfb51085cjim | rebackref
6aadbc6fd703e73d1d419e9f06b84a4338c898f1maczniak | function
78f97ce162b66a0dbfd7af4dcd9984f162569b04minfrin
f5a398cc8880978754903f9ece8e4beb63a81cedrbowenstring ::= stringpart
f5a398cc8880978754903f9ece8e4beb63a81cedrbowen | string stringpart
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bndstringpart ::= cstring
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd | variable
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd | rebackref
7906201913b68fe78b9d6a22ab33bf21d82c490eminfrin
7906201913b68fe78b9d6a22ab33bf21d82c490eminfrincstring ::= ...
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnddigit ::= [0-9]+
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd
05ede5110427cb9dc071cc671d5aaba5d3b88c79ndvariable ::= "<strong>%{</strong>" varname "<strong>}</strong>"
e8b603fa9ccf7b17b11b42df6d8916fd97c2331dnd | "<strong>%{</strong>" funcname "<strong>:</strong>" funcargs "<strong>}</strong>"
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd
4ed26c413f67a5aae20b95909828f30bb5dc2286poirierrebackref ::= "<strong>$</strong>" [0-9]
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bndfunction ::= funcname "<strong>(</strong>" word "<strong>)</strong>"
611049e38bfbaeb173d2d7fab2e44a48753436a1nd
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bndlistfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd</pre>
8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6bnd</blockquote>
a78048ccbdb6256da15e6b0e7e95355e480c2301nd
6aadbc6fd703e73d1d419e9f06b84a4338c898f1maczniak</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
6aadbc6fd703e73d1d419e9f06b84a4338c898f1maczniak<div class="section">
a78048ccbdb6256da15e6b0e7e95355e480c2301nd<h2><a name="vars" id="vars">Variables</a></h2>
a78048ccbdb6256da15e6b0e7e95355e480c2301nd
a78048ccbdb6256da15e6b0e7e95355e480c2301nd
03a4ff9ac4c9b8009249010e7c53bb86ff05915and <p>The expression parser provides a number of variables of the form
5effc8b39fae5cd169d17f342bfc265705840014rbowen <code>%{HTTP_HOST}</code>. Note that the value of a variable may depend
f21bea4c0f58e17aa1d9a0fac2c219852f89944amaczniak on the phase of the request processing in which it is evaluated. For
b43f840409794ed298e8634f6284741f193b6c4ftakashi example, an expression used in an <code class="directive">&lt;If &gt;</code>
b43f840409794ed298e8634f6284741f193b6c4ftakashi directive is evaluated before authentication is done. Therefore,
f21bea4c0f58e17aa1d9a0fac2c219852f89944amaczniak <code>%{REMOTE_USER}</code> will not be set in this case.</p>
4b5981e276e93df97c34e4da05ca5cf8bbd937dand
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd <p>The following variables provide the values of the named HTTP request
f21bea4c0f58e17aa1d9a0fac2c219852f89944amaczniak headers. The values of other headers can be obtained with the
6aadbc6fd703e73d1d419e9f06b84a4338c898f1maczniak <code>req</code> <a href="#functions">function</a>. Using these
2704de98885368683621b01c8f8f4e4b01557611takashi variables may cause the header name to be added to the Vary
2704de98885368683621b01c8f8f4e4b01557611takashi header of the HTTP response, except where otherwise noted for the
2704de98885368683621b01c8f8f4e4b01557611takashi directive accepting the expression.</p>
b43f840409794ed298e8634f6284741f193b6c4ftakashi
2704de98885368683621b01c8f8f4e4b01557611takashi <table class="bordered"><tr class="header"><th>Name</th></tr>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<tr><td><code>HTTP_ACCEPT</code></td></tr>
6aadbc6fd703e73d1d419e9f06b84a4338c898f1maczniak<tr class="odd"><td><code>HTTP_FORWARDED</code></td></tr>
c819c19c2f1ffbf3a3f12a4070cc6c3f4ea2a6f2sf<tr><td><code>HTTP_HOST</code></td></tr>
d2b809e5d72658bff23819d8b77f20e4939af541nd<tr class="odd"><td><code>HTTP_PROXY_CONNECTION</code></td></tr>
a78048ccbdb6256da15e6b0e7e95355e480c2301nd<tr><td><code>HTTP_REFERER</code></td></tr>
4ed26c413f67a5aae20b95909828f30bb5dc2286poirier<tr class="odd"><td><code>HTTP_USER_AGENT</code></td></tr>
4ed26c413f67a5aae20b95909828f30bb5dc2286poirier</table>
cd6c8de3bedcc401ee230159b0439fa20f44488etakashi
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd <p>Other request related variables</p>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd <table class="bordered"><tr class="header"><th>Name</th><th>Description</th></tr>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<tr><td><code>REQUEST_METHOD</code></td>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd <td>The HTTP method of the incoming request (e.g.
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd <code>GET</code>)</td></tr>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<tr class="odd"><td><code>REQUEST_SCHEME</code></td>
5effc8b39fae5cd169d17f342bfc265705840014rbowen <td>The scheme part of the request's URI</td></tr>
5effc8b39fae5cd169d17f342bfc265705840014rbowen<tr><td><code>REQUEST_URI</code></td>
27d778df0b517e1578f907d2e51eb961cd8ee5fbjim <td>The path part of the request's URI</td></tr>
a610901168de82df5fc5d99b8759fd80e0f70aeasf<tr class="odd"><td><code>DOCUMENT_URI</code></td>
a43bfa789f4e52dde53ae8e53fa0427b5c1cf977nd <td>Same as REQUEST_URI</td></tr>
a43bfa789f4e52dde53ae8e53fa0427b5c1cf977nd<tr><td><code>REQUEST_FILENAME</code></td>
28c9d384aa958b321280b4ac886941dcad25396bnd <td>The full local filesystem path to the file or script matching the
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd request, if this has already been determined by the server at the
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd time <code>REQUEST_FILENAME</code> is referenced. Otherwise, such
438b4817913a5ff55d9cad4c7ddf133330b4466ejim as when used in virtual host context, the same value as
438b4817913a5ff55d9cad4c7ddf133330b4466ejim <code>REQUEST_URI</code> </td></tr>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi<tr class="odd"><td><code>SCRIPT_FILENAME</code></td>
e5ce3ac0e9b720c0fa23782e29168a0810697fdetakashi <td>Same as <code>REQUEST_FILENAME</code></td></tr>
604c89126c27104f659d7a51b0113e3bd435faf8fielding<tr><td><code>LAST_MODIFIED</code></td>
50cb7e2b30597f481fee57bac945190f06ebcc58jorton <td>The date and time of last modification of the file in the format
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd <code>20101231235959</code>, if this has already been determined by
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd the server at the time <code>LAST_MODIFIED</code> is referenced.
4126704c4950bfd46d32ad54e3b106ac6d868a73sf </td></tr>
4126704c4950bfd46d32ad54e3b106ac6d868a73sf<tr class="odd"><td><code>SCRIPT_USER</code></td>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd <td>The user name of the owner of the script.</td></tr>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<tr><td><code>SCRIPT_GROUP</code></td>
0a69d9bb491d9810892a9949c01403a1de3c7ac2nd <td>The group name of the group of the script.</td></tr>
4ed26c413f67a5aae20b95909828f30bb5dc2286poirier<tr class="odd"><td><code>PATH_INFO</code></td>
4ed26c413f67a5aae20b95909828f30bb5dc2286poirier <td>The trailing path name information, see
5effc8b39fae5cd169d17f342bfc265705840014rbowen <code class="directive"><a href="/mod/core.html#acceptpathinfo">AcceptPathInfo</a></code></td></tr>
5effc8b39fae5cd169d17f342bfc265705840014rbowen<tr><td><code>QUERY_STRING</code></td>
9652bc3a93433d52f80579062986ead2afe0d11fsf <td>The query string of the current request</td></tr>
5f4e50966b2b9b58436a1651cbe588d1b595657ewrowe<tr class="odd"><td><code>IS_SUBREQ</code></td>
11495c9f0bd33e51a25b4d532beadfbcf9b944a3nilgun <td>"<code>true</code>" if the current request is a subrequest,
11495c9f0bd33e51a25b4d532beadfbcf9b944a3nilgun "<code>false</code>" otherwise</td></tr>
5f4e50966b2b9b58436a1651cbe588d1b595657ewrowe<tr><td><code>THE_REQUEST</code></td>
ecc5150d35c0dc5ee5119c2717e6660fa331abbftakashi <td>The complete request line (e.g.,
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd "<code>GET /index.html HTTP/1.1</code>")</td></tr>
50cb7e2b30597f481fee57bac945190f06ebcc58jorton<tr class="odd"><td><code>REMOTE_ADDR</code></td>
79b024b81f6bb3c44dce77a7552191daf8b522d2jim <td>The IP address of the remote host</td></tr>
f772e8f448c223e5ea306f1bf92d97d968f972d5jim<tr><td><code>REMOTE_HOST</code></td>
f772e8f448c223e5ea306f1bf92d97d968f972d5jim <td>The host name of the remote host</td></tr>
fac8c35bfb158112226ab43ddf84d59daca5dc30nd<tr class="odd"><td><code>REMOTE_USER</code></td>
f772e8f448c223e5ea306f1bf92d97d968f972d5jim <td>The name of the authenticated user (if any)</td></tr>
1de1266f0ea387d6373be8415745dfd2ab876341jim<tr><td><code>REMOTE_IDENT</code></td>
1de1266f0ea387d6373be8415745dfd2ab876341jim <td>The user name set by <code class="module"><a href="/mod/mod_ident.html">mod_ident</a></code></td></tr>
a78048ccbdb6256da15e6b0e7e95355e480c2301nd<tr class="odd"><td><code>SERVER_NAME</code></td>
a78048ccbdb6256da15e6b0e7e95355e480c2301nd <td>The <code class="directive"><a href="/mod/core.html#servername">ServerName</a></code> of
5effc8b39fae5cd169d17f342bfc265705840014rbowen the current vhost</td></tr>
5effc8b39fae5cd169d17f342bfc265705840014rbowen<tr><td><code>SERVER_PORT</code></td>
5effc8b39fae5cd169d17f342bfc265705840014rbowen <td>The server port of the current vhost, see
5effc8b39fae5cd169d17f342bfc265705840014rbowen <code class="directive"><a href="/mod/core.html#servername">ServerName</a></code></td></tr>
a78048ccbdb6256da15e6b0e7e95355e480c2301nd<tr class="odd"><td><code>SERVER_ADMIN</code></td>
a78048ccbdb6256da15e6b0e7e95355e480c2301nd <td>The <code class="directive"><a href="/mod/core.html#serveradmin">ServerAdmin</a></code> of
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd the current vhost</td></tr>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<tr><td><code>SERVER_PROTOCOL</code></td>
a78048ccbdb6256da15e6b0e7e95355e480c2301nd <td>The protocol used by the request</td></tr>
898711b68797304101de0882fa576c8908acfae6nd<tr class="odd"><td><code>DOCUMENT_ROOT</code></td>
a78048ccbdb6256da15e6b0e7e95355e480c2301nd <td>The <code class="directive"><a href="/mod/core.html#documentroot">DocumentRoot</a></code> of
a78048ccbdb6256da15e6b0e7e95355e480c2301nd the current vhost</td></tr>
a78048ccbdb6256da15e6b0e7e95355e480c2301nd<tr><td><code>AUTH_TYPE</code></td>
50cb7e2b30597f481fee57bac945190f06ebcc58jorton <td>The configured <code class="directive"><a href="/mod/mod_authn_core.html#authtype">AuthType</a></code>
a78048ccbdb6256da15e6b0e7e95355e480c2301nd (e.g. "<code>basic</code>")</td></tr>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<tr class="odd"><td><code>CONTENT_TYPE</code></td>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd <td>The content type of the response</td></tr>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<tr><td><code>HANDLER</code></td>
8e31885fc494b603e0650113dde9e29d1b1d2602maczniak <td>The name of the <a href="handler.html">handler</a> creating
03c25fb6f628ac81f2ecb637d1e7502dcee783f3nd the response</td></tr>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<tr class="odd"><td><code>HTTPS</code></td>
b43f840409794ed298e8634f6284741f193b6c4ftakashi <td>"<code>on</code>" if the request uses https,
b43f840409794ed298e8634f6284741f193b6c4ftakashi "<code>off</code>" otherwise</td></tr>
4126704c4950bfd46d32ad54e3b106ac6d868a73sf<tr><td><code>IPV6</code></td>
4126704c4950bfd46d32ad54e3b106ac6d868a73sf <td>"<code>on</code>" if the connection uses IPv6,
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd "<code>off</code>" otherwise</td></tr>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<tr class="odd"><td><code>REQUEST_STATUS</code></td>
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd <td>The HTTP error status of the request</td></tr>
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd<tr><td><code>REQUEST_LOG_ID</code></td>
ecc5150d35c0dc5ee5119c2717e6660fa331abbftakashi <td>The error log id of the request (see
bc9d4698fce0238d2f6f2682e99423ebb1149976rbowen <code class="directive"><a href="/mod/core.html#errorlogformat">ErrorLogFormat</a></code>)</td></tr>
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd<tr class="odd"><td><code>CONN_LOG_ID</code></td>
63f06dce77bb2d9b1c5aa5deeb47a1069987fd1end <td>The error log id of the connection (see
d474d8ef01ec5c2a09341cd148851ed383c3287crbowen <code class="directive"><a href="/mod/core.html#errorlogformat">ErrorLogFormat</a></code>)</td></tr>
d474d8ef01ec5c2a09341cd148851ed383c3287crbowen<tr><td><code>CONN_REMOTE_ADDR</code></td>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd <td>The peer IP address of the connection (see the
5effc8b39fae5cd169d17f342bfc265705840014rbowen <code class="module"><a href="/mod/mod_remoteip.html">mod_remoteip</a></code> module)</td></tr>
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen</table>
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen <p>Misc variables</p>
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen <table class="bordered"><tr class="header"><th>Name</th><th>Description</th></tr>
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd<tr><td><code>TIME_YEAR</code></td>
<td>The current year (e.g. <code>2010</code>)</td></tr>
<tr class="odd"><td><code>TIME_MON</code></td>
<td>The current month (<code>1</code>, ..., <code>12</code>)</td></tr>
<tr><td><code>TIME_DAY</code></td>
<td>The current day of the month</td></tr>
<tr class="odd"><td><code>TIME_HOUR</code></td>
<td>The hour part of the current time
(<code>0</code>, ..., <code>23</code>)</td></tr>
<tr><td><code>TIME_MIN</code></td>
<td>The minute part of the current time </td></tr>
<tr class="odd"><td><code>TIME_SEC</code></td>
<td>The second part of the current time </td></tr>
<tr><td><code>TIME_WDAY</code></td>
<td>The day of the week (starting with <code>0</code>
for Sunday)</td></tr>
<tr class="odd"><td><code>TIME</code></td>
<td>The date and time in the format <code>20101231235959</code></td></tr>
<tr><td><code>SERVER_SOFTWARE</code></td>
<td>The server version string</td></tr>
<tr class="odd"><td><code>API_VERSION</code></td>
<td>The date of the API version (module magic number)</td></tr>
</table>
<p>Some modules register additional variables, see e.g. <code class="module"><a href="/mod/mod_ssl.html">mod_ssl</a></code>.</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
<div class="section">
<h2><a name="binop" id="binop">Binary operators</a></h2>
<p>With the exception of some built-in comparison operators, binary
operators have the form "<code>-[a-zA-Z][a-zA-Z0-9_]+</code>", i.e. a
minus and at least two characters. The name is not case sensitive.
Modules may register additional binary operators.</p>
<h3><a name="comp" id="comp">Comparison operators</a></h3>
<table class="bordered"><tr class="header"><th>Name</th><th>Alternative</th> <th>Description</th></tr>
<tr><td><code>==</code></td>
<td><code>=</code></td>
<td>String equality</td></tr>
<tr class="odd"><td><code>!=</code></td>
<td />
<td>String inequality</td></tr>
<tr><td><code>&lt;</code></td>
<td />
<td>String less than</td></tr>
<tr class="odd"><td><code>&lt;=</code></td>
<td />
<td>String less than or equal</td></tr>
<tr><td><code>&gt;</code></td>
<td />
<td>String greater than</td></tr>
<tr class="odd"><td><code>&gt;=</code></td>
<td />
<td>String greater than or equal</td></tr>
<tr><td><code>-eq</code></td>
<td><code>eq</code></td>
<td>Integer equality</td></tr>
<tr class="odd"><td><code>-ne</code></td>
<td><code>ne</code></td>
<td>Integer inequality</td></tr>
<tr><td><code>-lt</code></td>
<td><code>lt</code></td>
<td>Integer less than</td></tr>
<tr class="odd"><td><code>-le</code></td>
<td><code>le</code></td>
<td>Integer less than or equal</td></tr>
<tr><td><code>-gt</code></td>
<td><code>gt</code></td>
<td>Integer greater than</td></tr>
<tr class="odd"><td><code>-ge</code></td>
<td><code>ge</code></td>
<td>Integer greater than or equal</td></tr>
</table>
<h3><a name="binaryother" id="binaryother">Other binary operators</a></h3>
<table class="bordered"><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td><code>-ipmatch</code></td>
<td>IP address matches address/netmask</td></tr>
<tr class="odd"><td><code>-strmatch</code></td>
<td>left string matches pattern given by right string (containing
wildcards *, ?, [])</td></tr>
<tr><td><code>-strcmatch</code></td>
<td>same as <code>-strmatch</code>, but case insensitive</td></tr>
<tr class="odd"><td><code>-fnmatch</code></td>
<td>same as <code>-strmatch</code>, but slashes are not matched by
wildcards</td></tr>
</table>
</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
<div class="section">
<h2><a name="unnop" id="unnop">Unary operators</a></h2>
<p>Unary operators take one argument and have the form
"<code>-[a-zA-Z]</code>", i.e. a minus and one character.
The name <em>is</em> case sensitive.
Modules may register additional unary operators.</p>
<table class="bordered"><tr class="header"><th>Name</th><th>Description</th><th>Restricted</th></tr>
<tr><td><code>-d</code></td>
<td>The argument is treated as a filename.
True if the file exists and is a directory</td><td>yes</td></tr>
<tr class="odd"><td><code>-e</code></td>
<td>The argument is treated as a filename.
True if the file (or dir or special) exists</td><td>yes</td></tr>
<tr><td><code>-f</code></td>
<td>The argument is treated as a filename.
True if the file exists and is regular file</td><td>yes</td></tr>
<tr class="odd"><td><code>-s</code></td>
<td>The argument is treated as a filename.
True if the file exists and is not empty</td><td>yes</td></tr>
<tr><td><code>-L</code></td>
<td>The argument is treated as a filename.
True if the file exists and is symlink</td><td>yes</td></tr>
<tr class="odd"><td><code>-h</code></td>
<td>The argument is treated as a filename.
True if the file exists and is symlink
(same as <code>-L</code>)</td><td>yes</td></tr>
<tr><td><code>-F</code></td>
<td>True if string is a valid file, accessible via all the server's
currently-configured access controls for that path. This uses an
internal subrequest to do the check, so use it with care - it can
impact your server's performance!</td><td /></tr>
<tr class="odd"><td><code>-U</code></td>
<td>True if string is a valid URL, accessible via all the server's
currently-configured access controls for that path. This uses an
internal subrequest to do the check, so use it with care - it can
impact your server's performance!</td><td /></tr>
<tr><td><code>-A</code></td>
<td>Alias for <code>-U</code></td><td /></tr>
<tr class="odd"><td><code>-n</code></td>
<td>True if string is not empty</td><td /></tr>
<tr><td><code>-z</code></td>
<td>True if string is empty</td><td /></tr>
<tr class="odd"><td><code>-T</code></td>
<td>False if string is empty, "<code>0</code>", "<code>off</code>",
"<code>false</code>", or "<code>no</code>" (case insensitive).
True otherwise.</td><td /></tr>
<tr><td><code>-R</code></td>
<td>Same as "<code>%{REMOTE_ADDR} -ipmatch ...</code>", but more efficient
</td><td /></tr>
</table>
<p>The operators marked as "restricted" are not available in some modules
like <code class="module"><a href="/mod/mod_include.html">mod_include</a></code>.</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
<div class="section">
<h2><a name="functions" id="functions">Functions</a></h2>
<p>Normal string-valued functions take one string as argument and return
a string. Functions names are not case sensitive.
Modules may register additional functions.</p>
<table class="bordered"><tr class="header"><th>Name</th><th>Description</th><th>Restricted</th></tr>
<tr><td><code>req</code>, <code>http</code></td>
<td>Get HTTP request header; header names may be added to the Vary
header, see below</td><td /></tr>
<tr class="odd"><td><code>resp</code></td>
<td>Get HTTP response header</td><td /></tr>
<tr><td><code>reqenv</code></td>
<td>Lookup request environment variable</td><td /></tr>
<tr class="odd"><td><code>osenv</code></td>
<td>Lookup operating system environment variable</td><td /></tr>
<tr><td><code>note</code></td>
<td>Lookup request note</td><td /></tr>
<tr class="odd"><td><code>env</code></td>
<td>Return first match of <code>note</code>, <code>reqenv</code>,
<code>osenv</code></td><td /></tr>
<tr><td><code>tolower</code></td>
<td>Convert string to lower case</td><td /></tr>
<tr class="odd"><td><code>toupper</code></td>
<td>Convert string to uppser case</td><td /></tr>
<tr><td><code>escape</code></td>
<td>Escape special characters in %hex encoding</td><td /></tr>
<tr class="odd"><td><code>unescape</code></td>
<td>Unescape %hex encoded string, leaving encoded slashes alone;
return empty string if %00 is found</td><td /></tr>
<tr><td><code>file</code></td>
<td>Read contents from a file</td><td>yes</td></tr>
<tr class="odd"><td><code>filesize</code></td>
<td>Return size of a file (or 0 if file does not exist or is not
regular file)</td><td>yes</td></tr>
</table>
<p>The functions marked as "restricted" are not available in some modules
like <code class="module"><a href="/mod/mod_include.html">mod_include</a></code>.</p>
<p>When the functions <code>req</code> or <code>http</code> are used,
the header name will automatically be added to the Vary header of the
HTTP response, except where otherwise noted for the directive accepting
the expression.</p>
<p>In addition to string-valued functions, there are also list-valued functions which
take one string as argument and return a wordlist, i.e. a list of strings. The wordlist
can be used with the special <code>-in</code> operator.
Functions names are not case sensitive.
Modules may register additional functions.</p>
<p>There are no built-in list-valued functions. <code class="module"><a href="/mod/mod_ssl.html">mod_ssl</a></code>
provides <code>PeerExtList</code>. See the description of
<code class="directive"><a href="/mod/mod_ssl.html#sslrequire">SSLRequire</a></code> for details
(but <code>PeerExtList</code> is also usable outside
of <code class="directive"><a href="/mod/mod_ssl.html#sslrequire">SSLRequire</a></code>).</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
<div class="section">
<h2><a name="examples" id="examples">Example expressions</a></h2>
<p>The following examples show how expressions might be used to evaluate requests:</p>
<pre class="prettyprint lang-config">
# Compare the host name to example.com and redirect to www.example.com if it matches
&lt;If "%{HTTP_HOST} == 'example.com'"&gt;
Redirect permanent / http://www.example.com
&lt;/If&gt;
# Force text/plain if requesting a file with the query string contains 'forcetext'
&lt;If "%{QUERY_STRING} =~ /forcetext/"&gt;
ForceType text/plain
&lt;/If&gt;
# Only allow access to this content during business hours
&lt;Directory "/foo/bar/business"&gt;
Require expr %{TIME_HOUR} -gt 9 &amp;&amp; %{TIME_HOUR} -lt 17
&lt;/Directory&gt;
</pre>
</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
<div class="section">
<h2><a name="other" id="other">Other</a></h2>
<table class="bordered"><tr class="header"><th>Name</th><th>Alternative</th> <th>Description</th></tr>
<tr><td><code>-in</code></td>
<td><code>in</code></td>
<td>string contained in string list</td></tr>
<tr class="odd"><td><code>/regexp/</code></td>
<td><code>m#regexp#</code></td>
<td>Regular expression (the second form allows different delimiters than /)</td></tr>
<tr><td><code>/regexp/i</code></td>
<td><code>m#regexp#i</code></td>
<td>Case insensitive regular expression</td></tr>
<tr class="odd"><td><code>$0 ... $9</code></td>
<td />
<td>Regular expression backreferences</td></tr>
</table>
<h3><a name="rebackref" id="rebackref">Regular expression backreferences</a></h3>
<p>The strings <code>$0</code> ... <code>$9</code> allow to reference
the capture groups from a previously executed, successfully
matching regular expressions. They can normally only be used in the
same expression as the matching regex, but some modules allow special
uses.</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
<div class="section">
<h2><a name="sslrequire" id="sslrequire">Comparison with SSLRequire</a></h2>
<p>The <em>ap_expr</em> syntax is mostly a superset of the syntax of the
deprecated <code class="directive"><a href="/mod/mod_ssl.html#sslrequire">SSLRequire</a></code> directive.
The differences are described in <code class="directive"><a href="/mod/mod_ssl.html#sslrequire">SSLRequire</a></code>'s documentation.</p>
</div></div>
<div class="bottomlang">
<p><span>Available Languages: </span><a href="/en/expr.html" title="English">&nbsp;en&nbsp;</a> |
<a href="/fr/expr.html" hreflang="fr" rel="alternate" title="Fran�ais">&nbsp;fr&nbsp;</a></p>
</div><div class="top"><a href="#page-header"><img src="/images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
<script type="text/javascript"><!--//--><![CDATA[//><!--
var comments_shortname = 'httpd';
var comments_identifier = 'http://httpd.apache.org/docs/trunk/expr.html';
(function(w, d) {
if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
d.write('<div id="comments_thread"><\/div>');
var s = d.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
(d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
}
else {
d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
}
})(window, document);
//--><!]]></script></div><div id="footer">
<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>
<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
if (typeof(prettyPrint) !== 'undefined') {
prettyPrint();
}
//--><!]]></script>
</body></html>