From: Christophe Jaillet
- HTTP_USER_AGENT
- HTTP_REFERER
+ HTTP_ACCEPT
HTTP_COOKIE
HTTP_FORWARDED
HTTP_HOST
HTTP_PROXY_CONNECTION
- HTTP_ACCEPT
+ HTTP_REFERER
+ HTTP_USER_AGENT
- REMOTE_ADDR
+ AUTH_TYPE
CONN_REMOTE_ADDR
+ CONTEXT_PREFIX
+ CONTEXT_DOCUMENT_ROOT
+ IPV6
+ PATH_INFO
+ QUERY_STRING
+ REMOTE_ADDR
REMOTE_HOST
+ REMOTE_IDENT
REMOTE_PORT
REMOTE_USER
- REMOTE_IDENT
REQUEST_METHOD
SCRIPT_FILENAME
- PATH_INFO
- QUERY_STRING
- AUTH_TYPE
@@ -242,9 +245,11 @@ Alias /myapp /opt/myapp-1.2.3
@@ -279,8 +284,8 @@ Alias /myapp /opt/myapp-1.2.3
correspond to the similarly named HTTP
MIME-headers, C variables of the Apache HTTP Server or
DOCUMENT_ROOT
+ SCRIPT_GROUP
+ SCRIPT_USER
+ SERVER_ADDR
SERVER_ADMIN
SERVER_NAME
- SERVER_ADDR
SERVER_PORT
SERVER_PROTOCOL
SERVER_SOFTWARE
@@ -263,14 +268,14 @@ Alias /myapp /opt/myapp-1.2.3
API_VERSION
- THE_REQUEST
- REQUEST_URI
- REQUEST_FILENAME
- IS_SUBREQ
+ CONN_REMOTE_ADDR
HTTPS
- REQUEST_SCHEME
+ IS_SUBREQ
REMOTE_ADDR
- CONN_REMOTE_ADDR
+ REQUEST_FILENAME
+ REQUEST_SCHEME
+ REQUEST_URI
+ THE_REQUEST
struct tm fields of the Unix system.
- Most are documented elsewhere in the Manual or in
- the CGI specification.
SERVER_NAME and SERVER_PORT depend on the values of
UseCanonicalName and
@@ -290,14 +295,6 @@ Alias /myapp /opt/myapp-1.2.3
Those that are special to mod_rewrite include those below.
IS_SUBREQAPI_VERSIONTHE_REQUESTCONN_REMOTE_ADDRGET
- /index.html HTTP/1.1"). This does not
- include any additional headers sent by the
- browser. This value has not been unescaped
- (decoded), unlike most other variables below.mod_remoteip module).REQUEST_URIHTTPSQUERY_STRING.mod_ssl is loaded).IS_SUBREQREMOTE_ADDRmod_remoteip module).REQUEST_FILENAMEREQUEST_URI to map the request to a file.
- HTTPSmod_ssl is loaded).REQUEST_SCHEMEServerName.REMOTE_ADDRmod_remoteip module).REQUEST_URICONN_REMOTE_ADDRmod_remoteip module).QUERY_STRING.THE_REQUESTGET
+ /index.html HTTP/1.1"). This does not
+ include any additional headers sent by the
+ browser. This value has not been unescaped
+ (decoded), unlike most other variables below.$N in the substitution string!
brackets, of any of the flags in the following table. More
details, and examples, for each flag, are available in the Rewrite Flags document.
- | Flag and syntax | +
|---|
| Flag and syntax | Function |
|---|---|
| B | Escape non-alphanumeric characters in backreferences before applying the transformation. details ... |
| backrefnoplus|BNP | If backreferences are being escaped, spaces should be escaped to %20 instead of +. Useful when the backreference will be used in the path component rather than the query string.details ... |
| chain|C | Rule is chained to the following rule. If the rule fails, the rule(s) chained to it will be skipped. details ... |
| cookie|CO=NAME:VAL | Sets a cookie in the client browser. Full syntax is: CO=NAME:VAL:domain[:lifetime[:path[:secure[:httponly]]]] details ... |
| discardpath|DPI | Causes the PATH_INFO portion of the rewritten URI to be discarded. details ... |
| END | Stop the rewriting process immediately and don't apply any more rules. Also prevents further execution of rewrite rules in per-directory and .htaccess context. (Available in 2.3.9 and later) details ... |
| env|E=[!]VAR[:VAL] | Causes an environment variable VAR to be set (to the value VAL if provided). The form !VAR causes the environment variable VAR to be unset. details ... |
| forbidden|F | Returns a 403 FORBIDDEN response to the client browser. details ... |
| gone|G | Returns a 410 GONE response to the client browser. details ... |
| Handler|H=Content-handler | Causes the resulting URI to be sent to the specified Content-handler for processing. details ... |
| last|L | Stop the rewriting process immediately and don't apply any more rules. Especially note caveats for per-directory and .htaccess context (see also the END flag). details ... |
| next|N | Re-run the rewriting process, starting again with the first rule, using the result of the ruleset so far as a starting point. details ... |
| nocase|NC | Makes the pattern comparison case-insensitive. details ... |
| noescape|NE | Prevent mod_rewrite from applying hexcode escaping of special characters in the result of the rewrite. details ... |
| nosubreq|NS | Causes a rule to be skipped if the current request is an internal sub-request. details ... |
| proxy|P | Force the substitution URL to be internally sent as a proxy request. details ... |
| passthrough|PT | Forces the resulting URI to be passed back to the URL
mapping engine for processing of other URI-to-filename
translators, such as Alias or
Redirect. details ... |
| qsappend|QSA | Appends any query string from the original request URL to any query string created in the rewrite target.details ... |
| qsdiscard|QSD | Discard any query string attached to the incoming URI. details ... |
| redirect|R[=code] | Forces an external redirect, optionally with the specified HTTP status code. details ... |
| skip|S=num | Tells the rewriting engine to skip the next num rules if the current rule matches. details ... |
| type|T=MIME-type | Force the MIME-type of the target file to be the specified type. details ... |
When the substitution string begins with a string @@ -1321,68 +1326,55 @@ directive.
/somepath/pathinfo'':| Given Rule | Resulting Substitution | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ^/somepath(.*) otherpath$1 | invalid, not supported | ||||||||||||||||||||||||
| ^/somepath(.*) otherpath$1 [R] | invalid, not supported | ||||||||||||||||||||||||
| ^/somepath(.*) otherpath$1 [P] | invalid, not supported | ||||||||||||||||||||||||
| ^/somepath(.*) /otherpath$1 | /otherpath/pathinfo | ||||||||||||||||||||||||
| ^/somepath(.*) /otherpath$1 [R] | http://thishost/otherpath/pathinfo via external redirection | ||||||||||||||||||||||||
| ^/somepath(.*) /otherpath$1 [P] | doesn't make sense, not supported | ||||||||||||||||||||||||
| ^/somepath(.*) http://thishost/otherpath$1 | /otherpath/pathinfo | ||||||||||||||||||||||||
| ^/somepath(.*) http://thishost/otherpath$1 [R] | http://thishost/otherpath/pathinfo via external redirection | ||||||||||||||||||||||||
| ^/somepath(.*) http://thishost/otherpath$1 [P] | doesn't make sense, not supported | ||||||||||||||||||||||||
| ^/somepath(.*) http://otherhost/otherpath$1 | http://otherhost/otherpath/pathinfo via external redirection | ||||||||||||||||||||||||
| ^/somepath(.*) http://otherhost/otherpath$1 [R] | http://otherhost/otherpath/pathinfo via external redirection (the [R] flag is redundant) | ||||||||||||||||||||||||
| ^/somepath(.*) http://otherhost/otherpath$1 [P] | http://otherhost/otherpath/pathinfo via internal proxy |
| Given Rule | Resulting Substitution |
|---|---|
| ^localpath(.*) otherpath$1 | /somepath/otherpath/pathinfo |
| ^localpath(.*) otherpath$1 [R] | http://thishost/somepath/otherpath/pathinfo via external redirection |
| ^localpath(.*) otherpath$1 [P] | doesn't make sense, not supported |
| ^localpath(.*) /otherpath$1 | /otherpath/pathinfo |
| ^localpath(.*) /otherpath$1 [R] | http://thishost/otherpath/pathinfo via external redirection |
| ^localpath(.*) /otherpath$1 [P] | doesn't make sense, not supported |
| ^localpath(.*) http://thishost/otherpath$1 | /otherpath/pathinfo |
| ^localpath(.*) http://thishost/otherpath$1 [R] | http://thishost/otherpath/pathinfo via external redirection |
| ^localpath(.*) http://thishost/otherpath$1 [P] | doesn't make sense, not supported |
| ^localpath(.*) http://otherhost/otherpath$1 | http://otherhost/otherpath/pathinfo via external redirection |
| ^localpath(.*) http://otherhost/otherpath$1 [R] | http://otherhost/otherpath/pathinfo via external redirection (the [R] flag is redundant) |
| ^localpath(.*) http://otherhost/otherpath$1 [P] | http://otherhost/otherpath/pathinfo via internal proxy |
struct tm fields of the Unix system.
- Most are documented elsewhere in the Manual or in
- the CGI specification.
+ Most are documented here
+ or elsewhere in the Manual or in the CGI specification.
SERVER_NAME and SERVER_PORT depend on the values of
Those that are special to mod_rewrite include those below.
IS_SUBREQAPI_VERSIONTHE_REQUESTCONN_REMOTE_ADDRGET
- /index.html HTTP/1.1"). This does not
- include any additional headers sent by the
- browser. This value has not been unescaped
- (decoded), unlike most other variables below.REQUEST_URIHTTPSQUERY_STRING.IS_SUBREQREMOTE_ADDRREQUEST_FILENAMEREQUEST_URI to map the request to a file.
- HTTPSREQUEST_SCHEMEREMOTE_ADDRREQUEST_URICONN_REMOTE_ADDRQUERY_STRING.THE_REQUESTGET
+ /index.html HTTP/1.1"). This does not
+ include any additional headers sent by the
+ browser. This value has not been unescaped
+ (decoded), unlike most other variables below.$N in the substitution string!
details, and examples, for each flag, are available in the Rewrite Flags document.
- | Flag and syntax | Function |
|---|
| Given Rule | Resulting Substitution | @@ -1423,7 +1430,7 @@ directive. /somepath/localpath/pathinfo'':
|---|
| Given Rule |
|---|