From 2a463b3cd73c32ee9dcd508248d0194923f435f4 Mon Sep 17 00:00:00 2001
From: Stefan Fritsch
Historically, there are several syntax variants for expressions used to express - a condition in the different modules of the Apache HTTP Server. - There is some ongoing effort to only use a single variant, called ap_expr, - for all configuration directives. - This document describes the ap_expr expression parser. +
Historically, there are several syntax variants for expressions + used to express a condition in the different modules of the Apache + HTTP Server. There is some ongoing effort to only use a single + variant, called ap_expr, for all configuration directives. + This document describes the ap_expr expression parser.
The ap_expr expression is intended to replace most other
- expression variants in HTTPD. For example, the deprecated
- SSLRequire
expressions can be
- replaced by Require expr.
-
SSLRequire
expressions can be replaced
+ by Require expr.
<If>
<ElseIf>
<Else>
AuthBasicFake
AuthFormLoginRequiredLocation
AuthFormLoginSuccessLocation
AuthFormLogoutLocation
RewriteCond
SetEnvIfExpr
Header
RequestHeader
FilterProvider
SSLRequire
LogMessage
mod_include
Backus-Naur Form (BNF) is a notation - technique for context-free grammars, often used to describe the syntax of languages used in computing. +
Backus-Naur
+ Form (BNF) is a notation technique for context-free grammars,
+ often used to describe the syntax of languages used in computing.
In most cases, expressions are used to express boolean values.
- For these, the starting point in the BNF is expr
. However, a few directives
- like LogMessage
accept expressions
- that evaluate to a string value. For those, the starting point in the BNF is string
.
+ For these, the starting point in the BNF is expr
.
+ However, a few directives like LogMessage
accept expressions
+ that evaluate to a string value. For those, the starting point in
+ the BNF is string
.
--expr ::= "true" | "false" +expr ::= "true" | "false" | "!" expr | expr "&&" expr | expr "||" expr @@ -119,8 +118,7 @@ rebackref ::= "$" [0-9] function ::= funcname "(" word ")" -listfunction ::= listfuncname "(" word ")" -+listfunction ::= listfuncname "(" word ")"
DocumentRoot
of
the current vhostAUTH_TYPE
AuthType
- (e.g. "basic
")AuthType
(e.g.
+ "basic
")CONTENT_TYPE
HANDLER
0
for Sunday)TIME
20101231235959
20101231235959
SERVER_SOFTWARE
API_VERSION
Some modules register additional variables, see e.g. mod_ssl
.
Some modules register additional variables, see e.g.
+ mod_ssl
.
false
", or "no
" (case insensitive).
True otherwise.-R
%{REMOTE_ADDR} -ipmatch ...
", but more efficient
+ %{REMOTE_ADDR} -ipmatch ...
", but more
+ efficient
resp
reqenv
v
can be used too to access variables).v
can be used too to access
+ variables).osenv
note
req_novary
function can be used to
prevent names from being added to the Vary header.
- 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 -in
operator.
- Functions names are not case sensitive.
- Modules may register additional functions.
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 -in
operator. Functions names are not case
+ sensitive. Modules may register additional functions.
There are no built-in list-valued functions. mod_ssl
provides PeerExtList
. See the description of
@@ -478,10 +481,10 @@ listfunction ::= listfuncname "(" word ")"
The following examples show how expressions might be used to evaluate requests:
+The following examples show how expressions might be used to + evaluate requests:
--# Compare the host name to example.com and redirect to www.example.com if it matches +# Compare the host name to example.com and redirect to www.example.com if it matches <If "%{HTTP_HOST} == 'example.com'"> Redirect permanent / http://www.example.com/ </If> @@ -493,9 +496,8 @@ listfunction ::= listfuncname "(" word ")" # Only allow access to this content during business hours <Directory "/foo/bar/business"> - Require expr "%{TIME_HOUR} -gt 9 && %{TIME_HOUR} -lt 17" -</Directory> -+ Require expr %{TIME_HOUR} -gt 9 && %{TIME_HOUR} -lt 17 +</Directory>
/regexp/
m#regexp#
/regexp/i
m#regexp#i