github.com/krum110487/go-htaccess@v0.0.0-20240316004156-60641c8e7598/tests/data/apache_2_2_34/manual/custom-error.html.en (about) 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 <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" /> 5 <!-- 6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 7 This file is generated from xml source: DO NOT EDIT 8 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 9 --> 10 <title>Custom Error Responses - Apache HTTP Server Version 2.2</title> 11 <link href="./style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> 12 <link href="./style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> 13 <link href="./style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="./style/css/prettify.css" /> 14 <script src="./style/scripts/prettify.min.js" type="text/javascript"> 15 </script> 16 17 <link href="./images/favicon.ico" rel="shortcut icon" /><link href="http://httpd.apache.org/docs/current/custom-error.html" rel="canonical" /></head> 18 <body id="manual-page"><div id="page-header"> 19 <p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p> 20 <p class="apache">Apache HTTP Server Version 2.2</p> 21 <img alt="" src="./images/feather.gif" /></div> 22 <div class="up"><a href="./"><img title="<-" alt="<-" src="./images/left.gif" /></a></div> 23 <div id="path"> 24 <a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="./">Version 2.2</a></div><div id="page-content"><div class="retired"><h4>Please note</h4> 25 <p> This document refers to a legacy release (<strong>2.2</strong>) of Apache httpd. The active release (<strong>2.4</strong>) is documented <a href="http://httpd.apache.org/docs/current">here</a>. If you have not already upgraded, please follow <a href="http://httpd.apache.org/docs/current/upgrading.html">this link</a> for more information.</p> 26 <p>You may follow <a href="http://httpd.apache.org/docs/current/custom-error.html">this link</a> to go to the current version of this document.</p></div><div id="preamble"><h1>Custom Error Responses</h1> 27 <div class="toplang"> 28 <p><span>Available Languages: </span><a href="./en/custom-error.html" title="English"> en </a> | 29 <a href="./es/custom-error.html" hreflang="es" rel="alternate" title="Español"> es </a> | 30 <a href="./ja/custom-error.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> | 31 <a href="./ko/custom-error.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> | 32 <a href="./tr/custom-error.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p> 33 </div> 34 35 <p>Additional functionality allows webmasters to configure the response 36 of Apache to some error or problem.</p> 37 38 <p>Customizable responses can be defined to be activated in the event of 39 a server detected error or problem.</p> 40 41 <p>If a script crashes and produces a "500 Server Error" response, 42 then this response can be replaced with either some friendlier text or by 43 a redirection to another URL (local or external).</p> 44 </div> 45 <div id="quickview"><ul id="toc"><li><img alt="" src="./images/down.gif" /> <a href="#behavior">Behavior</a></li> 46 <li><img alt="" src="./images/down.gif" /> <a href="#configuration">Configuration</a></li> 47 <li><img alt="" src="./images/down.gif" /> <a href="#custom">Custom Error Responses and Redirects</a></li> 48 </ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div> 49 <div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div> 50 <div class="section"> 51 <h2><a name="behavior" id="behavior">Behavior</a></h2> 52 53 54 <h3>Old Behavior</h3> 55 56 57 <p>NCSA httpd 1.3 would return some boring old error/problem message 58 which would often be meaningless to the user, and would provide no 59 means of logging the symptoms which caused it.</p> 60 61 62 <h3>New Behavior</h3> 63 64 65 <p>The server can be asked to:</p> 66 67 <ol> 68 <li>Display some other text, instead of the NCSA hard coded 69 messages, or</li> 70 71 <li>redirect to a local URL, or</li> 72 73 <li>redirect to an external URL.</li> 74 </ol> 75 76 <p>Redirecting to another URL can be useful, but only if some 77 information can be passed which can then be used to explain and/or log 78 the error/problem more clearly.</p> 79 80 <p>To achieve this, Apache will define new CGI-like environment 81 variables:</p> 82 83 <div class="example"><p><code> 84 REDIRECT_HTTP_ACCEPT=*/*, image/gif, image/x-xbitmap, 85 image/jpeg<br /> 86 REDIRECT_HTTP_USER_AGENT=Mozilla/1.1b2 (X11; I; HP-UX A.09.05 87 9000/712)<br /> 88 REDIRECT_PATH=.:/bin:/usr/local/bin:/etc<br /> 89 REDIRECT_QUERY_STRING=<br /> 90 REDIRECT_REMOTE_ADDR=121.345.78.123<br /> 91 REDIRECT_REMOTE_HOST=ooh.ahhh.com<br /> 92 REDIRECT_SERVER_NAME=crash.bang.edu<br /> 93 REDIRECT_SERVER_PORT=80<br /> 94 REDIRECT_SERVER_SOFTWARE=Apache/0.8.15<br /> 95 REDIRECT_URL=/cgi-bin/buggy.pl 96 </code></p></div> 97 98 <p>Note the <code>REDIRECT_</code> prefix.</p> 99 100 <p>At least <code>REDIRECT_URL</code> and 101 <code>REDIRECT_QUERY_STRING</code> will be passed to the 102 new URL (assuming it's a cgi-script or a cgi-include). The 103 other variables will exist only if they existed prior to 104 the error/problem. <strong>None</strong> of these will be 105 set if your <code class="directive"><a href="./mod/core.html#errordocument">ErrorDocument</a></code> is an 106 <em>external</em> redirect (anything starting with a 107 scheme name like <code>http:</code>, even if it refers to the same host 108 as the server).</p> 109 110 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div> 111 <div class="section"> 112 <h2><a name="configuration" id="configuration">Configuration</a></h2> 113 114 115 <p>Use of <code class="directive"><a href="./mod/core.html#errordocument">ErrorDocument</a></code> is enabled 116 for .htaccess files when the 117 <code class="directive"><a href="./mod/core.html#allowoverride">AllowOverride</a></code> is set accordingly.</p> 118 119 <p>Here are some examples...</p> 120 121 <div class="example"><p><code> 122 ErrorDocument 500 /cgi-bin/crash-recover <br /> 123 ErrorDocument 500 "Sorry, our script crashed. Oh dear" <br /> 124 ErrorDocument 500 http://xxx/ <br /> 125 ErrorDocument 404 /Lame_excuses/not_found.html <br /> 126 ErrorDocument 401 /Subscription/how_to_subscribe.html 127 </code></p></div> 128 129 <p>The syntax is,</p> 130 131 <div class="example"><p><code> 132 ErrorDocument <3-digit-code> <action> 133 </code></p></div> 134 135 <p>where the action can be,</p> 136 137 <ol> 138 <li>Text to be displayed. Wrap the text with quotes (").</li> 139 140 <li>An external URL to redirect to.</li> 141 142 <li>A local URL to redirect to.</li> 143 </ol> 144 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div> 145 <div class="section"> 146 <h2><a name="custom" id="custom">Custom Error Responses and Redirects</a></h2> 147 148 149 <p>Apache's behavior to redirected URLs has been modified so 150 that additional environment variables are available to a 151 script/server-include.</p> 152 153 <h3>Old behavior</h3> 154 155 156 <p>Standard CGI vars were made available to a script which 157 has been redirected to. No indication of where the 158 redirection came from was provided.</p> 159 160 161 <h3>New behavior</h3> 162 163 164 <p>A new batch of environment variables will be initialized 165 for use by a script which has been redirected to. Each new 166 variable will have the prefix <code>REDIRECT_</code>. 167 <code>REDIRECT_</code> environment variables are created from 168 the CGI environment variables which existed prior to the 169 redirect, they are renamed with a <code>REDIRECT_</code> 170 prefix, <em>i.e.</em>, <code>HTTP_USER_AGENT</code> becomes 171 <code>REDIRECT_HTTP_USER_AGENT</code>. In addition to these 172 new variables, Apache will define <code>REDIRECT_URL</code> 173 and <code>REDIRECT_STATUS</code> to help the script trace its 174 origin. Both the original URL and the URL being redirected to 175 can be logged in the access log.</p> 176 177 <p>If the ErrorDocument specifies a local redirect to a CGI 178 script, the script should include a "<code>Status:</code>" 179 header field in its output in order to ensure the propagation 180 all the way back to the client of the error condition that 181 caused it to be invoked. For instance, a Perl ErrorDocument 182 script might include the following:</p> 183 184 <div class="example"><p><code> 185 ... <br /> 186 print "Content-type: text/html\n"; <br /> 187 printf "Status: %s Condition Intercepted\n", $ENV{"REDIRECT_STATUS"}; <br /> 188 ... 189 </code></p></div> 190 191 <p>If the script is dedicated to handling a particular error 192 condition, such as <code>404 Not Found</code>, it can 193 use the specific code and error text instead.</p> 194 195 <p>Note that the script <em>must</em> emit an appropriate 196 <code>Status:</code> header (such as <code>302 Found</code>), if the 197 response contains a <code>Location:</code> header (in order to issue a 198 client side redirect). Otherwise the <code>Location:</code> header may 199 have no effect.</p> 200 201 </div></div> 202 <div class="bottomlang"> 203 <p><span>Available Languages: </span><a href="./en/custom-error.html" title="English"> en </a> | 204 <a href="./es/custom-error.html" hreflang="es" rel="alternate" title="Español"> es </a> | 205 <a href="./ja/custom-error.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> | 206 <a href="./ko/custom-error.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> | 207 <a href="./tr/custom-error.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p> 208 </div><div class="top"><a href="#page-header"><img src="./images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />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 <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div> 209 <script type="text/javascript"><!--//--><![CDATA[//><!-- 210 var comments_shortname = 'httpd'; 211 var comments_identifier = 'http://httpd.apache.org/docs/2.2/custom-error.html'; 212 (function(w, d) { 213 if (w.location.hostname.toLowerCase() == "httpd.apache.org") { 214 d.write('<div id="comments_thread"><\/div>'); 215 var s = d.createElement('script'); 216 s.type = 'text/javascript'; 217 s.async = true; 218 s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; 219 (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); 220 } 221 else { 222 d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); 223 } 224 })(window, document); 225 //--><!]]></script></div><div id="footer"> 226 <p class="apache">Copyright 2017 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> 227 <p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- 228 if (typeof(prettyPrint) !== 'undefined') { 229 prettyPrint(); 230 } 231 //--><!]]></script> 232 </body></html>