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