PageRenderTime 64ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/ctrl/manual/custom-error.html.en

https://bitbucket.org/neo7/webrasys
Unknown | 206 lines | 162 code | 44 blank | 0 comment | 0 complexity | 9ac61f2a79168e608affc0178d13841f MD5 | raw file
Possible License(s): Apache-2.0
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
  4. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  5. This file is generated from xml source: DO NOT EDIT
  6. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  7. -->
  8. <title>Custom Error Responses - Apache HTTP Server</title>
  9. <link href="./style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
  10. <link href="./style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
  11. <link href="./style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
  12. <link href="./images/favicon.ico" rel="shortcut icon" /></head>
  13. <body id="manual-page"><div id="page-header">
  14. <p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p>
  15. <p class="apache">Apache HTTP Server Version 2.0</p>
  16. <img alt="" src="./images/feather.gif" /></div>
  17. <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="./images/left.gif" /></a></div>
  18. <div id="path">
  19. <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs-project/">Documentation</a> &gt; <a href="./">Version 2.0</a></div><div id="page-content"><div id="preamble"><h1>Custom Error Responses</h1>
  20. <div class="toplang">
  21. <p><span>Available Languages: </span><a href="./en/custom-error.html" title="English">&nbsp;en&nbsp;</a> |
  22. <a href="./es/custom-error.html" hreflang="es" rel="alternate" title="Español">&nbsp;es&nbsp;</a> |
  23. <a href="./fr/custom-error.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a> |
  24. <a href="./ja/custom-error.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
  25. <a href="./ko/custom-error.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a></p>
  26. </div>
  27. <p>Additional functionality allows webmasters to configure the response
  28. of Apache to some error or problem.</p>
  29. <p>Customizable responses can be defined to be activated in the event of
  30. a server detected error or problem.</p>
  31. <p>If a script crashes and produces a "500 Server Error" response,
  32. then this response can be replaced with either some friendlier text or by
  33. a redirection to another URL (local or external).</p>
  34. </div>
  35. <div id="quickview"><ul id="toc"><li><img alt="" src="./images/down.gif" /> <a href="#behavior">Behavior</a></li>
  36. <li><img alt="" src="./images/down.gif" /> <a href="#configuration">Configuration</a></li>
  37. <li><img alt="" src="./images/down.gif" /> <a href="#custom">Custom Error Responses and Redirects</a></li>
  38. </ul></div>
  39. <div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
  40. <div class="section">
  41. <h2><a name="behavior" id="behavior">Behavior</a></h2>
  42. <h3>Old Behavior</h3>
  43. <p>NCSA httpd 1.3 would return some boring old error/problem message
  44. which would often be meaningless to the user, and would provide no
  45. means of logging the symptoms which caused it.</p>
  46. <h3>New Behavior</h3>
  47. <p>The server can be asked to:</p>
  48. <ol>
  49. <li>Display some other text, instead of the NCSA hard coded
  50. messages, or</li>
  51. <li>redirect to a local URL, or</li>
  52. <li>redirect to an external URL.</li>
  53. </ol>
  54. <p>Redirecting to another URL can be useful, but only if some
  55. information can be passed which can then be used to explain and/or log
  56. the error/problem more clearly.</p>
  57. <p>To achieve this, Apache will define new CGI-like environment
  58. variables:</p>
  59. <div class="example"><p><code>
  60. REDIRECT_HTTP_ACCEPT=*/*, image/gif, image/x-xbitmap,
  61. image/jpeg<br />
  62. REDIRECT_HTTP_USER_AGENT=Mozilla/1.1b2 (X11; I; HP-UX A.09.05
  63. 9000/712)<br />
  64. REDIRECT_PATH=.:/bin:/usr/local/bin:/etc<br />
  65. REDIRECT_QUERY_STRING=<br />
  66. REDIRECT_REMOTE_ADDR=121.345.78.123<br />
  67. REDIRECT_REMOTE_HOST=ooh.ahhh.com<br />
  68. REDIRECT_SERVER_NAME=crash.bang.edu<br />
  69. REDIRECT_SERVER_PORT=80<br />
  70. REDIRECT_SERVER_SOFTWARE=Apache/0.8.15<br />
  71. REDIRECT_URL=/cgi-bin/buggy.pl
  72. </code></p></div>
  73. <p>Note the <code>REDIRECT_</code> prefix.</p>
  74. <p>At least <code>REDIRECT_URL</code> and
  75. <code>REDIRECT_QUERY_STRING</code> will be passed to the
  76. new URL (assuming it's a cgi-script or a cgi-include). The
  77. other variables will exist only if they existed prior to
  78. the error/problem. <strong>None</strong> of these will be
  79. set if your <code class="directive"><a href="./mod/core.html#errordocument">ErrorDocument</a></code> is an
  80. <em>external</em> redirect (anything starting with a
  81. scheme name like <code>http:</code>, even if it refers to the same host
  82. as the server).</p>
  83. </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
  84. <div class="section">
  85. <h2><a name="configuration" id="configuration">Configuration</a></h2>
  86. <p>Use of <code class="directive"><a href="./mod/core.html#errordocument">ErrorDocument</a></code> is enabled
  87. for .htaccess files when the
  88. <code class="directive"><a href="./mod/core.html#allowoverride">AllowOverride</a></code> is set accordingly.</p>
  89. <p>Here are some examples...</p>
  90. <div class="example"><p><code>
  91. ErrorDocument 500 /cgi-bin/crash-recover <br />
  92. ErrorDocument 500 "Sorry, our script crashed. Oh dear" <br />
  93. ErrorDocument 500 http://xxx/ <br />
  94. ErrorDocument 404 /Lame_excuses/not_found.html <br />
  95. ErrorDocument 401 /Subscription/how_to_subscribe.html
  96. </code></p></div>
  97. <p>The syntax is,</p>
  98. <div class="example"><p><code>
  99. ErrorDocument &lt;3-digit-code&gt; &lt;action&gt;
  100. </code></p></div>
  101. <p>where the action can be,</p>
  102. <ol>
  103. <li>Text to be displayed. Prefix the text with a quote
  104. ("). Whatever follows the quote is displayed. <em>Note:
  105. the (") prefix isn't displayed.</em></li>
  106. <li>An external URL to redirect to.</li>
  107. <li>A local URL to redirect to.</li>
  108. </ol>
  109. </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
  110. <div class="section">
  111. <h2><a name="custom" id="custom">Custom Error Responses and Redirects</a></h2>
  112. <p>Apache's behavior to redirected URLs has been modified so
  113. that additional environment variables are available to a
  114. script/server-include.</p>
  115. <h3>Old behavior</h3>
  116. <p>Standard CGI vars were made available to a script which
  117. has been redirected to. No indication of where the
  118. redirection came from was provided.</p>
  119. <h3>New behavior</h3>
  120. <p>A new batch of environment variables will be initialized
  121. for use by a script which has been redirected to. Each new
  122. variable will have the prefix <code>REDIRECT_</code>.
  123. <code>REDIRECT_</code> environment variables are created from
  124. the CGI environment variables which existed prior to the
  125. redirect, they are renamed with a <code>REDIRECT_</code>
  126. prefix, <em>i.e.</em>, <code>HTTP_USER_AGENT</code> becomes
  127. <code>REDIRECT_HTTP_USER_AGENT</code>. In addition to these
  128. new variables, Apache will define <code>REDIRECT_URL</code>
  129. and <code>REDIRECT_STATUS</code> to help the script trace its
  130. origin. Both the original URL and the URL being redirected to
  131. can be logged in the access log.</p>
  132. <p>If the ErrorDocument specifies a local redirect to a CGI
  133. script, the script should include a "<code>Status:</code>"
  134. header field in its output in order to ensure the propagation
  135. all the way back to the client of the error condition that
  136. caused it to be invoked. For instance, a Perl ErrorDocument
  137. script might include the following:</p>
  138. <div class="example"><p><code>
  139. ... <br />
  140. print "Content-type: text/html\n"; <br />
  141. printf "Status: %s Condition Intercepted\n", $ENV{"REDIRECT_STATUS"}; <br />
  142. ...
  143. </code></p></div>
  144. <p>If the script is dedicated to handling a particular error
  145. condition, such as <code>404&nbsp;Not&nbsp;Found</code>, it can
  146. use the specific code and error text instead.</p>
  147. <p>Note that the script <em>must</em> emit an appropriate
  148. <code>Status:</code> header (such as <code>302&nbsp;Found</code>), if the
  149. response contains a <code>Location:</code> header (in order to issue a
  150. client side redirect). Otherwise the <code>Location:</code> header may
  151. have no effect.</p>
  152. </div></div>
  153. <div class="bottomlang">
  154. <p><span>Available Languages: </span><a href="./en/custom-error.html" title="English">&nbsp;en&nbsp;</a> |
  155. <a href="./es/custom-error.html" hreflang="es" rel="alternate" title="Español">&nbsp;es&nbsp;</a> |
  156. <a href="./fr/custom-error.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a> |
  157. <a href="./ja/custom-error.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
  158. <a href="./ko/custom-error.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a></p>
  159. </div><div id="footer">
  160. <p class="apache">Copyright 1995-2005 The Apache Software Foundation or its licensors, as applicable.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
  161. <p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p></div>
  162. </body></html>