0N/A<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
0N/A<
TITLE>Custom error responses</
TITLE>
0N/A<!-- Background white, links blue (unvisited), navy (visited), red (active) --> 0N/A<
H1 ALIGN="CENTER">Custom error responses</
H1>
0N/A <
DD>Additional functionality. Allows webmasters to configure the response of
0N/A Apache to some error or problem.
0N/A <
P>Customizable responses can be defined to be activated in the
0N/A event of a server detected error or problem.
0N/A <
P>
e.g. if a script crashes and produces a "500 Server Error"
0N/A response, then this response can be replaced with either some
0N/A friendlier text or by a redirection to another URL (local or
0N/A which would often be meaningless to the user, and would provide no
0N/A means of logging the symptoms which caused it.<
BR>
0N/A <
DD>The server can be asked to;
0N/A <
LI>Display some other text, instead of the NCSA hard coded messages, or
0N/A <
LI>redirect to a local URL, or
0N/A <
LI>redirect to an external URL.
0N/A <
P>Redirecting to another URL can be useful, but only if some information
0N/A <
P>To achieve this, Apache will define new CGI-like environment
0N/AREDIRECT_QUERY_STRING= <
br>
0N/AREDIRECT_REMOTE_ADDR=121.345.78.123 <
br>
0N/AREDIRECT_SERVER_PORT=80 <
br>
0N/A </
code></
blockquote>
0N/A <
P>note the <
code>REDIRECT_</
code> prefix.
0N/A <
P>At least <
code>REDIRECT_URL</
code> and <
code>REDIRECT_QUERY_STRING</
code> will
0N/A be passed to the new URL (assuming it's a cgi-script or a cgi-include). The
0N/A other variables will exist only if they existed prior to the
error/
problem.
0N/A <
b>None</
b> of these will be set if your ErrorDocument is an
0N/A <
i>external</
i> redirect (
i.e. anything starting with a protocol name
0N/A like <
code>http:</
code>, even if it refers to the same host as the
0N/A <
DD> Use of "ErrorDocument" is enabled for .htaccess files when the
0N/A <
P>Here are some examples...
0N/AErrorDocument 500 "Sorry, our script crashed. Oh dear<
br>
0N/A </
code></
blockquote>
0N/A<3-digit-code> action
0N/A <
P>where the action can be,
0N/A <
LI>Text to be displayed. Prefix the text with a quote ("). Whatever
0N/A follows the quote is displayed. <
em>Note: the (") prefix isn't
0N/A <
LI>An external URL to redirect to.
0N/A <
LI>A local URL to redirect to.
0N/A<
h2>Custom error responses and redirects</
H2>
0N/A <
DD>Apache's behavior to redirected URLs has been modified so that additional
0N/A <
DD>Standard CGI vars were made available to a script which has been
0N/A redirected to. No indication of where the redirection came from was provided.
0N/AA new batch of environment variables will be initialized for use by a
0N/Ascript which has been redirected to. Each new variable will have the
0N/Aprefix <
code>REDIRECT_</
code>. <
code>REDIRECT_</
code> environment
0N/Avariables are created from the CGI environment variables which existed
0N/Aprior to the redirect, they are renamed with a <
code>REDIRECT_</
code>
0N/Aprefix,
i.e. <
code>HTTP_USER_AGENT</
code> becomes
0N/A<
code>REDIRECT_HTTP_USER_AGENT</
code>. In addition to these new
0N/Avariables, Apache will define <
code>REDIRECT_URL</
code> and
0N/A<
code>REDIRECT_STATUS</
code> to help the script trace its origin.
0N/ABoth the original URL and the URL being redirected to can be logged in