At least REDIRECT_URL and
REDIRECT_QUERY_STRING will be passed to the
new URL (assuming it's a cgi-script or a cgi-include). The
other variables will exist only if they existed prior to
the error/problem. None of these will be
set if your ErrorDocument is an
external redirect (anything starting with a
scheme name like http:, even if it refers to the same host
as the server).

Apache's behavior to redirected URLs has been modified so
that additional environment variables are available to a
script/server-include.

Old behavior

Standard CGI vars were made available to a script which
has been redirected to. No indication of where the
redirection came from was provided.

New behavior

A new batch of environment variables will be initialized
for use by a script which has been redirected to. Each new
variable will have the prefix REDIRECT_.
REDIRECT_ environment variables are created from
the CGI environment variables which existed prior to the
redirect, they are renamed with a REDIRECT_
prefix, i.e., HTTP_USER_AGENT becomes
REDIRECT_HTTP_USER_AGENT. In addition to these
new variables, Apache will define REDIRECT_URL
and REDIRECT_STATUS to help the script trace its
origin. Both the original URL and the URL being redirected to
can be logged in the access log.

If the ErrorDocument specifies a local redirect to a CGI
script, the script should include a "Status:"
header field in its output in order to ensure the propagation
all the way back to the client of the error condition that
caused it to be invoked. For instance, a Perl ErrorDocument
script might include the following:

If the script is dedicated to handling a particular error
condition, such as 404 Not Found, it can
use the specific code and error text instead.

Note that the script must emit an appropriate
Status: header (such as 302 Found), if the
response contains a Location: header (in order to issue a
client side redirect). Otherwise the Location: header may
have no effect.

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.