|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
|
|
Packit |
90a5c9 |
<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" />
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
|
Packit |
90a5c9 |
This file is generated from xml source: DO NOT EDIT
|
|
Packit |
90a5c9 |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
|
Packit |
90a5c9 |
-->
|
|
Packit |
90a5c9 |
<title>Expressions in Apache HTTP Server - Apache HTTP Server Version 2.4</title>
|
|
Packit |
90a5c9 |
<link href="./style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
|
|
Packit |
90a5c9 |
<link href="./style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
|
|
Packit |
90a5c9 |
<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" />
|
|
Packit |
90a5c9 |
<script src="./style/scripts/prettify.min.js" type="text/javascript">
|
|
Packit |
90a5c9 |
</script>
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
<link href="./images/favicon.ico" rel="shortcut icon" /></head>
|
|
Packit |
90a5c9 |
<body id="manual-page">
|
|
Packit |
90a5c9 |
Modules | Directives | FAQ | Glossary | Sitemap
|
|
Packit |
90a5c9 |
Apache HTTP Server Version 2.4
|
|
Packit |
90a5c9 |
![](./images/feather.png)
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Apache > HTTP Server > Documentation > Version 2.4Expressions in Apache HTTP Server
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Available Languages: en |
|
|
Packit |
90a5c9 |
fr
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Historically, there are several syntax variants for expressions
|
|
Packit |
90a5c9 |
used to express a condition in the different modules of the Apache
|
|
Packit |
90a5c9 |
HTTP Server. There is some ongoing effort to only use a single
|
|
Packit |
90a5c9 |
variant, called ap_expr, for all configuration directives.
|
|
Packit |
90a5c9 |
This document describes the ap_expr expression parser.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
The ap_expr expression is intended to replace most other
|
|
Packit |
90a5c9 |
expression variants in HTTPD. For example, the deprecated SSLRequire expressions can be replaced
|
|
Packit |
90a5c9 |
by Require expr.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Variables
|
|
Packit |
90a5c9 |
Binary operators
|
|
Packit |
90a5c9 |
Unary operators
|
|
Packit |
90a5c9 |
Functions
|
|
Packit |
90a5c9 |
Example expressions
|
|
Packit |
90a5c9 |
Other
|
|
Packit |
90a5c9 |
Comparison with SSLRequire
|
|
Packit |
90a5c9 |
Version History
|
|
Packit |
90a5c9 |
See also
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Backus-Naur
|
|
Packit |
90a5c9 |
Form (BNF) is a notation technique for context-free grammars,
|
|
Packit |
90a5c9 |
often used to describe the syntax of languages used in computing.
|
|
Packit |
90a5c9 |
In most cases, expressions are used to express boolean values.
|
|
Packit |
90a5c9 |
For these, the starting point in the BNF is expr .
|
|
Packit |
90a5c9 |
However, a few directives like LogMessage accept expressions
|
|
Packit |
90a5c9 |
that evaluate to a string value. For those, the starting point in
|
|
Packit |
90a5c9 |
the BNF is string .
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
expr ::= "true" | "false"
|
|
Packit |
90a5c9 |
| "!" expr
|
|
Packit |
90a5c9 |
| expr "&&" expr
|
|
Packit |
90a5c9 |
| expr "||" expr
|
|
Packit |
90a5c9 |
| "(" expr ")"
|
|
Packit |
90a5c9 |
| comp
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
comp ::= stringcomp
|
|
Packit |
90a5c9 |
| integercomp
|
|
Packit |
90a5c9 |
| unaryop word
|
|
Packit |
90a5c9 |
| word binaryop word
|
|
Packit |
90a5c9 |
| word "in" "{" wordlist "}"
|
|
Packit |
90a5c9 |
| word "in" listfunction
|
|
Packit |
90a5c9 |
| word "=~" regex
|
|
Packit |
90a5c9 |
| word "!~" regex
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
stringcomp ::= word "==" word
|
|
Packit |
90a5c9 |
| word "!=" word
|
|
Packit |
90a5c9 |
| word "<" word
|
|
Packit |
90a5c9 |
| word "<=" word
|
|
Packit |
90a5c9 |
| word ">" word
|
|
Packit |
90a5c9 |
| word ">=" word
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
integercomp ::= word "-eq" word | word "eq" word
|
|
Packit |
90a5c9 |
| word "-ne" word | word "ne" word
|
|
Packit |
90a5c9 |
| word "-lt" word | word "lt" word
|
|
Packit |
90a5c9 |
| word "-le" word | word "le" word
|
|
Packit |
90a5c9 |
| word "-gt" word | word "gt" word
|
|
Packit |
90a5c9 |
| word "-ge" word | word "ge" word
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
wordlist ::= word
|
|
Packit |
90a5c9 |
| wordlist "," word
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
word ::= word "." word
|
|
Packit |
90a5c9 |
| digit
|
|
Packit |
90a5c9 |
| "'" string "'"
|
|
Packit |
90a5c9 |
| """ string """
|
|
Packit |
90a5c9 |
| variable
|
|
Packit |
90a5c9 |
| rebackref
|
|
Packit |
90a5c9 |
| function
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
string ::= stringpart
|
|
Packit |
90a5c9 |
| string stringpart
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
stringpart ::= cstring
|
|
Packit |
90a5c9 |
| variable
|
|
Packit |
90a5c9 |
| rebackref
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
cstring ::= ...
|
|
Packit |
90a5c9 |
digit ::= [0-9]+
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
variable ::= "%{" varname "}"
|
|
Packit |
90a5c9 |
| "%{" funcname ":" funcargs "}"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
rebackref ::= "$" [0-9]
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
function ::= funcname "(" word ")"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
listfunction ::= listfuncname "(" word ")"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
The expression parser provides a number of variables of the form
|
|
Packit |
90a5c9 |
%{HTTP_HOST} . Note that the value of a variable may depend
|
|
Packit |
90a5c9 |
on the phase of the request processing in which it is evaluated. For
|
|
Packit |
90a5c9 |
example, an expression used in an <If >
|
|
Packit |
90a5c9 |
directive is evaluated before authentication is done. Therefore,
|
|
Packit |
90a5c9 |
%{REMOTE_USER} will not be set in this case.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
The following variables provide the values of the named HTTP request
|
|
Packit |
90a5c9 |
headers. The values of other headers can be obtained with the
|
|
Packit |
90a5c9 |
req function. Using these
|
|
Packit |
90a5c9 |
variables may cause the header name to be added to the Vary
|
|
Packit |
90a5c9 |
header of the HTTP response, except where otherwise noted for the
|
|
Packit |
90a5c9 |
directive accepting the expression. The req_novary
|
|
Packit |
90a5c9 |
function may be used to circumvent this
|
|
Packit |
90a5c9 |
behavior.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
HTTP_ACCEPT
|
|
Packit |
90a5c9 |
HTTP_COOKIE
|
|
Packit |
90a5c9 |
HTTP_FORWARDED
|
|
Packit |
90a5c9 |
HTTP_HOST
|
|
Packit |
90a5c9 |
HTTP_PROXY_CONNECTION
|
|
Packit |
90a5c9 |
HTTP_REFERER
|
|
Packit |
90a5c9 |
HTTP_USER_AGENT
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Other request related variables
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
REQUEST_METHOD
|
|
Packit |
90a5c9 |
The HTTP method of the incoming request (e.g.
|
|
Packit |
90a5c9 |
GET )
|
|
Packit |
90a5c9 |
REQUEST_SCHEME
|
|
Packit |
90a5c9 |
The scheme part of the request's URI
|
|
Packit |
90a5c9 |
REQUEST_URI
|
|
Packit |
90a5c9 |
The path part of the request's URI
|
|
Packit |
90a5c9 |
DOCUMENT_URI
|
|
Packit |
90a5c9 |
Same as REQUEST_URI
|
|
Packit |
90a5c9 |
REQUEST_FILENAME
|
|
Packit |
90a5c9 |
The full local filesystem path to the file or script matching the
|
|
Packit |
90a5c9 |
request, if this has already been determined by the server at the
|
|
Packit |
90a5c9 |
time REQUEST_FILENAME is referenced. Otherwise, such
|
|
Packit |
90a5c9 |
as when used in virtual host context, the same value as
|
|
Packit |
90a5c9 |
REQUEST_URI
|
|
Packit |
90a5c9 |
SCRIPT_FILENAME
|
|
Packit |
90a5c9 |
Same as REQUEST_FILENAME
|
|
Packit |
90a5c9 |
LAST_MODIFIED
|
|
Packit |
90a5c9 |
The date and time of last modification of the file in the format
|
|
Packit |
90a5c9 |
20101231235959 , if this has already been determined by
|
|
Packit |
90a5c9 |
the server at the time LAST_MODIFIED is referenced.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
SCRIPT_USER
|
|
Packit |
90a5c9 |
The user name of the owner of the script.
|
|
Packit |
90a5c9 |
SCRIPT_GROUP
|
|
Packit |
90a5c9 |
The group name of the group of the script.
|
|
Packit |
90a5c9 |
PATH_INFO
|
|
Packit |
90a5c9 |
The trailing path name information, see
|
|
Packit |
90a5c9 |
AcceptPathInfo
|
|
Packit |
90a5c9 |
QUERY_STRING
|
|
Packit |
90a5c9 |
The query string of the current request
|
|
Packit |
90a5c9 |
IS_SUBREQ
|
|
Packit |
90a5c9 |
"true " if the current request is a subrequest,
|
|
Packit |
90a5c9 |
"false " otherwise
|
|
Packit |
90a5c9 |
THE_REQUEST
|
|
Packit |
90a5c9 |
The complete request line (e.g.,
|
|
Packit |
90a5c9 |
"GET /index.html HTTP/1.1 ")
|
|
Packit |
90a5c9 |
REMOTE_ADDR
|
|
Packit |
90a5c9 |
The IP address of the remote host
|
|
Packit |
90a5c9 |
REMOTE_PORT
|
|
Packit |
90a5c9 |
The port of the remote host (2.4.26 and later)
|
|
Packit |
90a5c9 |
REMOTE_HOST
|
|
Packit |
90a5c9 |
The host name of the remote host
|
|
Packit |
90a5c9 |
REMOTE_USER
|
|
Packit |
90a5c9 |
The name of the authenticated user, if any (not available during <If> )
|
|
Packit |
90a5c9 |
REMOTE_IDENT
|
|
Packit |
90a5c9 |
The user name set by mod_ident
|
|
Packit |
90a5c9 |
SERVER_NAME
|
|
Packit |
90a5c9 |
The ServerName of
|
|
Packit |
90a5c9 |
the current vhost
|
|
Packit |
90a5c9 |
SERVER_PORT
|
|
Packit |
90a5c9 |
The server port of the current vhost, see
|
|
Packit |
90a5c9 |
ServerName
|
|
Packit |
90a5c9 |
SERVER_ADMIN
|
|
Packit |
90a5c9 |
The ServerAdmin of
|
|
Packit |
90a5c9 |
the current vhost
|
|
Packit |
90a5c9 |
SERVER_PROTOCOL
|
|
Packit |
90a5c9 |
The protocol used by the request
|
|
Packit |
90a5c9 |
DOCUMENT_ROOT
|
|
Packit |
90a5c9 |
The DocumentRoot of
|
|
Packit |
90a5c9 |
the current vhost
|
|
Packit |
90a5c9 |
AUTH_TYPE
|
|
Packit |
90a5c9 |
The configured AuthType (e.g.
|
|
Packit |
90a5c9 |
"basic ")
|
|
Packit |
90a5c9 |
CONTENT_TYPE
|
|
Packit |
90a5c9 |
The content type of the response (not available during <If> )
|
|
Packit |
90a5c9 |
HANDLER
|
|
Packit |
90a5c9 |
The name of the handler creating
|
|
Packit |
90a5c9 |
the response
|
|
Packit |
90a5c9 |
HTTP2
|
|
Packit |
90a5c9 |
"on " if the request uses http/2,
|
|
Packit |
90a5c9 |
"off " otherwise
|
|
Packit |
90a5c9 |
HTTPS
|
|
Packit |
90a5c9 |
"on " if the request uses https,
|
|
Packit |
90a5c9 |
"off " otherwise
|
|
Packit |
90a5c9 |
IPV6
|
|
Packit |
90a5c9 |
"on " if the connection uses IPv6,
|
|
Packit |
90a5c9 |
"off " otherwise
|
|
Packit |
90a5c9 |
REQUEST_STATUS
|
|
Packit |
90a5c9 |
The HTTP error status of the request (not available during <If> )
|
|
Packit |
90a5c9 |
REQUEST_LOG_ID
|
|
Packit |
90a5c9 |
The error log id of the request (see
|
|
Packit |
90a5c9 |
ErrorLogFormat )
|
|
Packit |
90a5c9 |
CONN_LOG_ID
|
|
Packit |
90a5c9 |
The error log id of the connection (see
|
|
Packit |
90a5c9 |
ErrorLogFormat )
|
|
Packit |
90a5c9 |
CONN_REMOTE_ADDR
|
|
Packit |
90a5c9 |
The peer IP address of the connection (see the
|
|
Packit |
90a5c9 |
mod_remoteip module)
|
|
Packit |
90a5c9 |
CONTEXT_PREFIX
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
CONTEXT_DOCUMENT_ROOT
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Misc variables
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
TIME_YEAR
|
|
Packit |
90a5c9 |
The current year (e.g. 2010 )
|
|
Packit |
90a5c9 |
TIME_MON
|
|
Packit |
90a5c9 |
The current month (01 , ..., 12 )
|
|
Packit |
90a5c9 |
TIME_DAY
|
|
Packit |
90a5c9 |
The current day of the month (01 , ...)
|
|
Packit |
90a5c9 |
TIME_HOUR
|
|
Packit |
90a5c9 |
The hour part of the current time
|
|
Packit |
90a5c9 |
(00 , ..., 23 )
|
|
Packit |
90a5c9 |
TIME_MIN
|
|
Packit |
90a5c9 |
The minute part of the current time
|
|
Packit |
90a5c9 |
TIME_SEC
|
|
Packit |
90a5c9 |
The second part of the current time
|
|
Packit |
90a5c9 |
TIME_WDAY
|
|
Packit |
90a5c9 |
The day of the week (starting with 0
|
|
Packit |
90a5c9 |
for Sunday)
|
|
Packit |
90a5c9 |
TIME
|
|
Packit |
90a5c9 |
The date and time in the format
|
|
Packit |
90a5c9 |
20101231235959
|
|
Packit |
90a5c9 |
SERVER_SOFTWARE
|
|
Packit |
90a5c9 |
The server version string
|
|
Packit |
90a5c9 |
API_VERSION
|
|
Packit |
90a5c9 |
The date of the API version (module magic number)
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Some modules register additional variables, see e.g.
|
|
Packit |
90a5c9 |
mod_ssl .
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
With the exception of some built-in comparison operators, binary
|
|
Packit |
90a5c9 |
operators have the form "-[a-zA-Z][a-zA-Z0-9_]+ ", i.e. a
|
|
Packit |
90a5c9 |
minus and at least two characters. The name is not case sensitive.
|
|
Packit |
90a5c9 |
Modules may register additional binary operators.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Name | Alternative | Description |
---|
|
|
Packit |
90a5c9 |
==
|
|
Packit |
90a5c9 |
=
|
|
Packit |
90a5c9 |
String equality
|
|
Packit |
90a5c9 |
!=
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
String inequality
|
|
Packit |
90a5c9 |
<
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
String less than
|
|
Packit |
90a5c9 |
<=
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
String less than or equal
|
|
Packit |
90a5c9 |
>
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
String greater than
|
|
Packit |
90a5c9 |
>=
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
String greater than or equal
|
|
Packit |
90a5c9 |
=~
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
String matches the regular expression
|
|
Packit |
90a5c9 |
!~
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
String does not match the regular expression
|
|
Packit |
90a5c9 |
-eq
|
|
Packit |
90a5c9 |
eq
|
|
Packit |
90a5c9 |
Integer equality
|
|
Packit |
90a5c9 |
-ne
|
|
Packit |
90a5c9 |
ne
|
|
Packit |
90a5c9 |
Integer inequality
|
|
Packit |
90a5c9 |
-lt
|
|
Packit |
90a5c9 |
lt
|
|
Packit |
90a5c9 |
Integer less than
|
|
Packit |
90a5c9 |
-le
|
|
Packit |
90a5c9 |
le
|
|
Packit |
90a5c9 |
Integer less than or equal
|
|
Packit |
90a5c9 |
-gt
|
|
Packit |
90a5c9 |
gt
|
|
Packit |
90a5c9 |
Integer greater than
|
|
Packit |
90a5c9 |
-ge
|
|
Packit |
90a5c9 |
ge
|
|
Packit |
90a5c9 |
Integer greater than or equal
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
-ipmatch
|
|
Packit |
90a5c9 |
IP address matches address/netmask
|
|
Packit |
90a5c9 |
-strmatch
|
|
Packit |
90a5c9 |
left string matches pattern given by right string (containing
|
|
Packit |
90a5c9 |
wildcards *, ?, [])
|
|
Packit |
90a5c9 |
-strcmatch
|
|
Packit |
90a5c9 |
same as -strmatch , but case insensitive
|
|
Packit |
90a5c9 |
-fnmatch
|
|
Packit |
90a5c9 |
same as -strmatch , but slashes are not matched by
|
|
Packit |
90a5c9 |
wildcards
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Unary operators take one argument and have the form
|
|
Packit |
90a5c9 |
"-[a-zA-Z] ", i.e. a minus and one character.
|
|
Packit |
90a5c9 |
The name is case sensitive.
|
|
Packit |
90a5c9 |
Modules may register additional unary operators.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Name | Description | Restricted |
---|
|
|
Packit |
90a5c9 |
-d
|
|
Packit |
90a5c9 |
The argument is treated as a filename.
|
|
Packit |
90a5c9 |
True if the file exists and is a directoryyes
|
|
Packit |
90a5c9 |
-e
|
|
Packit |
90a5c9 |
The argument is treated as a filename.
|
|
Packit |
90a5c9 |
True if the file (or dir or special) existsyes
|
|
Packit |
90a5c9 |
-f
|
|
Packit |
90a5c9 |
The argument is treated as a filename.
|
|
Packit |
90a5c9 |
True if the file exists and is regular fileyes
|
|
Packit |
90a5c9 |
-s
|
|
Packit |
90a5c9 |
The argument is treated as a filename.
|
|
Packit |
90a5c9 |
True if the file exists and is not emptyyes
|
|
Packit |
90a5c9 |
-L
|
|
Packit |
90a5c9 |
The argument is treated as a filename.
|
|
Packit |
90a5c9 |
True if the file exists and is symlinkyes
|
|
Packit |
90a5c9 |
-h
|
|
Packit |
90a5c9 |
The argument is treated as a filename.
|
|
Packit |
90a5c9 |
True if the file exists and is symlink
|
|
Packit |
90a5c9 |
(same as -L )yes
|
|
Packit |
90a5c9 |
-F
|
|
Packit |
90a5c9 |
True if string is a valid file, accessible via all the server's
|
|
Packit |
90a5c9 |
currently-configured access controls for that path. This uses an
|
|
Packit |
90a5c9 |
internal subrequest to do the check, so use it with care - it can
|
|
Packit |
90a5c9 |
impact your server's performance!
|
|
Packit |
90a5c9 |
-U
|
|
Packit |
90a5c9 |
True if string is a valid URL, accessible via all the server's
|
|
Packit |
90a5c9 |
currently-configured access controls for that path. This uses an
|
|
Packit |
90a5c9 |
internal subrequest to do the check, so use it with care - it can
|
|
Packit |
90a5c9 |
impact your server's performance!
|
|
Packit |
90a5c9 |
-A
|
|
Packit |
90a5c9 |
Alias for -U
|
|
Packit |
90a5c9 |
-n
|
|
Packit |
90a5c9 |
True if string is not empty
|
|
Packit |
90a5c9 |
-z
|
|
Packit |
90a5c9 |
True if string is empty
|
|
Packit |
90a5c9 |
-T
|
|
Packit |
90a5c9 |
False if string is empty, "0 ", "off ",
|
|
Packit |
90a5c9 |
"false ", or "no " (case insensitive).
|
|
Packit |
90a5c9 |
True otherwise.
|
|
Packit |
90a5c9 |
-R
|
|
Packit |
90a5c9 |
Same as "%{REMOTE_ADDR} -ipmatch ... ", but more
|
|
Packit |
90a5c9 |
efficient
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
The operators marked as "restricted" are not available in some modules
|
|
Packit |
90a5c9 |
like mod_include .
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Normal string-valued functions take one string as argument and return
|
|
Packit |
90a5c9 |
a string. Functions names are not case sensitive.
|
|
Packit |
90a5c9 |
Modules may register additional functions.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Name | Description | Special notes |
---|
|
|
Packit |
90a5c9 |
req , http
|
|
Packit |
90a5c9 |
Get HTTP request header; header names may be added to the Vary
|
|
Packit |
90a5c9 |
header, see below
|
|
Packit |
90a5c9 |
req_novary
|
|
Packit |
90a5c9 |
Same as req , but header names will not be added to the
|
|
Packit |
90a5c9 |
Vary header
|
|
Packit |
90a5c9 |
resp
|
|
Packit |
90a5c9 |
Get HTTP response header (most response headers will not yet be set
|
|
Packit |
90a5c9 |
during <If> )
|
|
Packit |
90a5c9 |
reqenv
|
|
Packit |
90a5c9 |
Lookup request environment variable (as a shortcut,
|
|
Packit |
90a5c9 |
v can also be used to access variables).
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
ordering
|
|
Packit |
90a5c9 |
osenv
|
|
Packit |
90a5c9 |
Lookup operating system environment variable
|
|
Packit |
90a5c9 |
note
|
|
Packit |
90a5c9 |
Lookup request noteordering
|
|
Packit |
90a5c9 |
env
|
|
Packit |
90a5c9 |
Return first match of note , reqenv ,
|
|
Packit |
90a5c9 |
osenv ordering
|
|
Packit |
90a5c9 |
tolower
|
|
Packit |
90a5c9 |
Convert string to lower case
|
|
Packit |
90a5c9 |
toupper
|
|
Packit |
90a5c9 |
Convert string to upper case
|
|
Packit |
90a5c9 |
escape
|
|
Packit |
90a5c9 |
Escape special characters in %hex encoding
|
|
Packit |
90a5c9 |
unescape
|
|
Packit |
90a5c9 |
Unescape %hex encoded string, leaving encoded slashes alone;
|
|
Packit |
90a5c9 |
return empty string if %00 is found
|
|
Packit |
90a5c9 |
base64
|
|
Packit |
90a5c9 |
Encode the string using base64 encoding
|
|
Packit |
90a5c9 |
unbase64
|
|
Packit |
90a5c9 |
Decode base64 encoded string, return truncated string if 0x00 is
|
|
Packit |
90a5c9 |
found
|
|
Packit |
90a5c9 |
md5
|
|
Packit |
90a5c9 |
Hash the string using MD5, then encode the hash with hexadecimal
|
|
Packit |
90a5c9 |
encoding
|
|
Packit |
90a5c9 |
sha1
|
|
Packit |
90a5c9 |
Hash the string using SHA1, then encode the hash with hexadecimal
|
|
Packit |
90a5c9 |
encoding
|
|
Packit |
90a5c9 |
file
|
|
Packit |
90a5c9 |
Read contents from a file (including line endings, when present)
|
|
Packit |
90a5c9 |
restricted
|
|
Packit |
90a5c9 |
filemod
|
|
Packit |
90a5c9 |
Return last modification time of a file (or 0 if file does not exist
|
|
Packit |
90a5c9 |
or is not regular file)restricted
|
|
Packit |
90a5c9 |
filesize
|
|
Packit |
90a5c9 |
Return size of a file (or 0 if file does not exist or is not
|
|
Packit |
90a5c9 |
regular file)restricted
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
The functions marked as "restricted" in the final column are not
|
|
Packit |
90a5c9 |
available in some modules like mod_include .
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
The functions marked as "ordering" in the final column require some
|
|
Packit |
90a5c9 |
consideration for the ordering of different components of the server,
|
|
Packit |
90a5c9 |
especially when the function is used within the
|
|
Packit |
90a5c9 |
<If > directive which is
|
|
Packit |
90a5c9 |
evaluated relatively early.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Environment variable ordering
|
|
Packit |
90a5c9 |
When environment variables are looked up within an
|
|
Packit |
90a5c9 |
<If > condition, it's important
|
|
Packit |
90a5c9 |
to consider how extremely early in request processing that this
|
|
Packit |
90a5c9 |
resolution occurs. As a guideline, any directive defined outside of virtual host
|
|
Packit |
90a5c9 |
context (directory, location, htaccess) is not likely to have yet had a
|
|
Packit |
90a5c9 |
chance to execute. SetEnvIf
|
|
Packit |
90a5c9 |
in virtual host scope is one directive that runs prior to this resolution
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
When reqenv is used outside of <If >, the resolution will generally occur later, but the
|
|
Packit |
90a5c9 |
exact timing depends on the directive the expression has been used within.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
When the functions req or http are used,
|
|
Packit |
90a5c9 |
the header name will automatically be added to the Vary header of the
|
|
Packit |
90a5c9 |
HTTP response, except where otherwise noted for the directive accepting
|
|
Packit |
90a5c9 |
the expression. The req_novary function can be used to
|
|
Packit |
90a5c9 |
prevent names from being added to the Vary header.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
In addition to string-valued functions, there are also
|
|
Packit |
90a5c9 |
list-valued functions which take one string as argument and return a
|
|
Packit |
90a5c9 |
wordlist, i.e. a list of strings. The wordlist can be used with the
|
|
Packit |
90a5c9 |
special -in operator. Functions names are not case
|
|
Packit |
90a5c9 |
sensitive. Modules may register additional functions.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
There are no built-in list-valued functions. mod_ssl
|
|
Packit |
90a5c9 |
provides PeerExtList . See the description of
|
|
Packit |
90a5c9 |
SSLRequire for details
|
|
Packit |
90a5c9 |
(but PeerExtList is also usable outside
|
|
Packit |
90a5c9 |
of SSLRequire ).
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
The following examples show how expressions might be used to
|
|
Packit |
90a5c9 |
evaluate requests:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
# Compare the host name to example.com and redirect to www.example.com if it matches
|
|
Packit |
90a5c9 |
<If "%{HTTP_HOST} == 'example.com'">
|
|
Packit |
90a5c9 |
Redirect permanent "/" "http://www.example.com/"
|
|
Packit |
90a5c9 |
</If>
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
# Force text/plain if requesting a file with the query string contains 'forcetext'
|
|
Packit |
90a5c9 |
<If "%{QUERY_STRING} =~ /forcetext/">
|
|
Packit |
90a5c9 |
ForceType text/plain
|
|
Packit |
90a5c9 |
</If>
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
# Only allow access to this content during business hours
|
|
Packit |
90a5c9 |
<Directory "/foo/bar/business">
|
|
Packit |
90a5c9 |
Require expr %{TIME_HOUR} -gt 9 && %{TIME_HOUR} -lt 17
|
|
Packit |
90a5c9 |
</Directory>
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
# Check a HTTP header for a list of values
|
|
Packit |
90a5c9 |
<If "%{HTTP:X-example-header} in { 'foo', 'bar', 'baz' }">
|
|
Packit |
90a5c9 |
Header set matched true
|
|
Packit |
90a5c9 |
</If>
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
# Check an environment variable for a regular expression, negated.
|
|
Packit |
90a5c9 |
<If "! reqenv('REDIRECT_FOO') =~ /bar/">
|
|
Packit |
90a5c9 |
Header set matched true
|
|
Packit |
90a5c9 |
</If>
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
# Check result of URI mapping by running in Directory context with -f
|
|
Packit |
90a5c9 |
<Directory "/var/www">
|
|
Packit |
90a5c9 |
AddEncoding x-gzip gz
|
|
Packit |
90a5c9 |
<If "-f '%{REQUEST_FILENAME}.unzipme' && ! %{HTTP:Accept-Encoding} =~ /gzip/">
|
|
Packit |
90a5c9 |
SetOutputFilter INFLATE
|
|
Packit |
90a5c9 |
</If>
|
|
Packit |
90a5c9 |
</Directory>
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
# Check against the client IP
|
|
Packit |
90a5c9 |
<If "-R '192.168.1.0/24'">
|
|
Packit |
90a5c9 |
Header set matched true
|
|
Packit |
90a5c9 |
</If>
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
# Function example in boolean context
|
|
Packit |
90a5c9 |
<If "md5('foo') == 'acbd18db4cc2f85cedef654fccc4a4d8'">
|
|
Packit |
90a5c9 |
Header set checksum-matched true
|
|
Packit |
90a5c9 |
</If>
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
# Function example in string context
|
|
Packit |
90a5c9 |
Header set foo-checksum "expr=%{md5:foo}"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
# This delays the evaluation of the condition clause compared to <If>
|
|
Packit |
90a5c9 |
Header always set CustomHeader my-value "expr=%{REQUEST_URI} =~ m#^/special_path\.php$#"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
# Conditional logging
|
|
Packit |
90a5c9 |
CustomLog logs/access-errors.log common "expr=%{REQUEST_STATUS} >= 400"
|
|
Packit |
90a5c9 |
CustomLog logs/access-errors-specific.log common "expr=%{REQUEST_STATUS} -in {'405','410'}"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Name | Alternative | Description |
---|
|
|
Packit |
90a5c9 |
-in
|
|
Packit |
90a5c9 |
in
|
|
Packit |
90a5c9 |
string contained in wordlist
|
|
Packit |
90a5c9 |
/regexp/
|
|
Packit |
90a5c9 |
m#regexp#
|
|
Packit |
90a5c9 |
Regular expression (the second form allows different
|
|
Packit |
90a5c9 |
delimiters than /)
|
|
Packit |
90a5c9 |
/regexp/i
|
|
Packit |
90a5c9 |
m#regexp#i
|
|
Packit |
90a5c9 |
Case insensitive regular expression
|
|
Packit |
90a5c9 |
$0 ... $9
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Regular expression backreferences
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
The strings $0 ... $9 allow to reference
|
|
Packit |
90a5c9 |
the capture groups from a previously executed, successfully
|
|
Packit |
90a5c9 |
matching regular expressions. They can normally only be used in the
|
|
Packit |
90a5c9 |
same expression as the matching regex, but some modules allow special
|
|
Packit |
90a5c9 |
uses.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
The ap_expr syntax is mostly a superset of the syntax of the
|
|
Packit |
90a5c9 |
deprecated SSLRequire directive.
|
|
Packit |
90a5c9 |
The differences are described in SSLRequire 's documentation.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
The req_novary function
|
|
Packit |
90a5c9 |
is available for versions 2.4.4 and later.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Available Languages: en |
|
|
Packit |
90a5c9 |
fr
|
|
Packit |
90a5c9 |
Notice:This is not a Q&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 mailing lists.
|
|
Packit |
90a5c9 |
<script type="text/javascript">
|
|
Packit |
90a5c9 |
var comments_shortname = 'httpd';
|
|
Packit |
90a5c9 |
var comments_identifier = 'http://httpd.apache.org/docs/2.4/expr.html';
|
|
Packit |
90a5c9 |
(function(w, d) {
|
|
Packit |
90a5c9 |
if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
|
|
Packit |
90a5c9 |
d.write('
|
|
Packit |
90a5c9 |
var s = d.createElement('script');
|
|
Packit |
90a5c9 |
s.type = 'text/javascript';
|
|
Packit |
90a5c9 |
s.async = true;
|
|
Packit |
90a5c9 |
s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
|
|
Packit |
90a5c9 |
(d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
else {
|
|
Packit |
90a5c9 |
d.write('
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
})(window, document);
|
|
Packit |
90a5c9 |
//--></script>
|
|
Packit |
90a5c9 |
Copyright 2018 The Apache Software Foundation. Licensed under the Apache License, Version 2.0.
|
|
Packit |
90a5c9 |
Modules | Directives | FAQ | Glossary | Sitemap <script type="text/javascript">
|
|
Packit |
90a5c9 |
if (typeof(prettyPrint) !== 'undefined') {
|
|
Packit |
90a5c9 |
prettyPrint();
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
//--></script>
|
|
Packit |
90a5c9 |
</body></html>
|