⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 custom_errordocs.html.en

📁 Apache_2.0.59-Openssl_0.9 配置tomcat. Apache_2.0.59-Openssl_0.9 配置tomcat.
💻 EN
📖 第 1 页 / 共 2 页
字号:
    and in mod_include.</p>

    <p>See <a href="#listings">the listings below</a> to see an
    actual HTML implementation of the discussed example.</p>
    

    <h3><a name="createdocs" id="createdocs">Creating ErrorDocuments in Different Languages</a></h3>

    

    <p>After all this preparation work, little remains to be said
    about the actual documents. They all share a simple common
    structure:</p>

<div class="example"><p><code>
&lt;!--#set var="title" value="<em>error description title</em>" --&gt; <br />
&lt;!--#include virtual="head" --&gt; <br />
<span class="indent">
 <em>explanatory error text</em> <br />
</span>
&lt;!--#include virtual="foot" --&gt;
</code></p></div>

    <p>In the <a href="#listings">listings section</a>, you can see an
    example of a [400 Bad Request] error document. Documents as
    simple as that certainly cause no problems to translate or
    expand.</p>
    

    <h3><a name="fallback" id="fallback">The Fallback Language</a></h3>

    

    <p>Do we need a special handling for languages other than those we
    have translations for? We did set the LanguagePriority, didn't
    we?!</p>

    <p>Well, the LanguagePriority directive is for the case where
    the client does not express any language priority at all. But
    what happens in the situation where the client wants one of the
    languages we do not have, and none of those we do have?</p>

    <p>Without doing anything, the Apache server will usually
    return a [406 no acceptable variant] error, listing the choices
    from which the client may select. But we're in an error message
    already, and important error information might get lost when
    the client had to choose a language representation first.</p>

    <p>So, in this situation it appears to be easier to define a
    fallback language (by copying or linking, <em>e.g.</em>, the
    english version to a language-less version). Because the
    negotiation algorithm prefers "more specialized" variants over
    "more generic" variants, these generic alternatives will only
    be chosen when the normal negotiation did not succeed.</p>

    <p>A simple shell script to do it (execute within the
    errordocs/ dir):</p>

<div class="example"><p><code>
  for f in *.shtml.en <br />
  do <br />
  <span class="indent">
     ln -s $f `basename $f .en` <br />
  </span>
  done
</code></p></div>

    
  </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="proxy" id="proxy">Customizing Proxy Error Messages</a></h2>

  

    <p>As of Apache-1.3, it is possible to use the
    <code>ErrorDocument</code> mechanism for proxy error messages
    as well (previous versions always returned fixed predefined
    error messages).</p>

    <p>Most proxy errors return an error code of [500 Internal
    Server Error]. To find out whether a particular error document
    was invoked on behalf of a proxy error or because of some other
    server error, and what the reason for the failure was, you can
    check the contents of the new <code>ERROR_NOTES</code> CGI
    environment variable: if invoked for a proxy error, this
    variable will contain the actual proxy error message text in
    HTML form.</p>

    <p>The following excerpt demonstrates how to exploit the
    <code>ERROR_NOTES</code> variable within an error document:</p>

<div class="example"><p><code>
 &lt;!--#if expr="$REDIRECT_ERROR_NOTES = ''" --&gt; <br />
 <br />
  &lt;p&gt; <br />
  <span class="indent">
   The server encountered an unexpected condition <br />
   which prevented it from fulfilling the request. <br />
  </span>
  &lt;/p&gt; <br />
<br />
  &lt;p&gt; <br />
  <span class="indent">
   &lt;a href="mailto:&lt;!--#echo var="SERVER_ADMIN" --&gt;" <br />
    SUBJECT="Error message [&lt;!--#echo var="REDIRECT_STATUS" --&gt;] &lt;!--#echo var="title" --&gt; for &lt;!--#echo var="REQUEST_URI" --&gt;"&gt; <br />
   Please forward this error screen to &lt;!--#echo var="SERVER_NAME" --&gt;'s <br />
   WebMaster&lt;/a&gt;; it includes useful debugging information about <br />
   the Request which caused the error. <br />
<br />
   &lt;pre&gt;&lt;!--#printenv --&gt;&lt;/pre&gt; <br />
  </span>
  &lt;/p&gt; <br />
 <br />
 &lt;!--#else --&gt; <br />
 <span class="indent">
  &lt;!--#echo var="REDIRECT_ERROR_NOTES" --&gt;<br />
 </span>
<br />
 &lt;!--#endif --&gt;
</code></p></div>

  </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="listings" id="listings">HTML Listing of the Discussed Example</a></h2>

  

    <p>So, to summarize our example, here's the complete listing of
    the <code>400.shtml.en</code> document. You will notice that it
    contains almost nothing but the error text (with conditional
    additions). Starting with this example, you will find it easy
    to add more error documents, or to translate the error
    documents to different languages.</p>

<div class="example"><p><code>
&lt;!--#set var="title" value="Bad Request"--&gt; <br />
&lt;!--#include virtual="head" --&gt;<br />
<br />
   &lt;p&gt; <br />
   <span class="indent">
   Your browser sent a request that this server could not understand: <br />
   &lt;blockquote&gt; <br />
     <span class="indent">
     &lt;strong&gt;&lt;!--#echo var="REQUEST_URI" --&gt;&lt;/strong&gt;<br />
     </span>
   &lt;/blockquote&gt; <br />
   <br />
   The request could not be understood by the server due to malformed <br />
   syntax. The client should not repeat the request without <br />
   modifications. <br />
   </span>
   &lt;/p&gt; <br />
<br />
   &lt;p&gt; <br />
   <span class="indent">
   &lt;!--#if expr="$HTTP_REFERER != ''" --&gt; <br />
    <span class="indent">
    Please inform the owner of <br />
    &lt;a href="&lt;!--#echo var="HTTP_REFERER" --&gt;"&gt;the referring page&lt;/a&gt; about <br />
    the malformed link. <br />
    </span>
   <br />
   &lt;!--#else --&gt; <br />
    <span class="indent">
    Please check your request for typing errors and retry. <br />
    </span>
   <br />
   &lt;!--#endif --&gt; <br />
   </span>
   &lt;/p&gt; <br />
<br />
&lt;!--#include virtual="foot" --&gt;
</code></p></div>

    <p>Here is the complete <code>head.shtml.en</code> file (the funny
    line breaks avoid empty lines in the document after SSI
    processing). Note the configuration section at top. That's
    where you configure the images and logos as well as the apache
    documentation directory. Look how this file displays two
    different logos depending on the content of the virtual host
    name ($SERVER_NAME), and that an animated apache logo is shown
    if the browser appears to support it (the latter requires
    server configuration lines of the form </p>

    <div class="example"><p><code>BrowserMatch "^Mozilla/[2-4]" anigif</code></p></div>

    <p>for browser types which support animated GIFs).</p>

<div class="example"><p><code>
&lt;!--#if expr="$SERVER_NAME = /.*\.mycompany\.com/" --&gt;<br />
<span class="indent">
&lt;!--#set var="IMG_CorpLogo" value="http://$SERVER_NAME:$SERVER_PORT/errordocs/CorpLogo.gif" --&gt;<br />
&lt;!--#set var="ALT_CorpLogo" value="Powered by Linux!" --&gt;<br />
</span>
<br />
&lt;!--#else --&gt; <br />
<span class="indent">
&lt;!--#set var="IMG_CorpLogo" value="http://$SERVER_NAME:$SERVER_PORT/errordocs/PrivLogo.gif" --&gt; <br />
&lt;!--#set var="ALT_CorpLogo" value="Powered by Linux!" --&gt; <br />
</span>
&lt;!--#endif--&gt; <br />
<br />
&lt;!--#set var="IMG_BgImage" value="http://$SERVER_NAME:$SERVER_PORT/errordocs/BgImage.gif" --&gt; <br />
&lt;!--#set var="DOC_Apache" value="http://$SERVER_NAME:$SERVER_PORT/Apache/" --&gt; <br />
<br />
&lt;!--#if expr="$anigif" --&gt; <br />
<span class="indent">
&lt;!--#set var="IMG_Apache" value="http://$SERVER_NAME:$SERVER_PORT/icons/apache_anim.gif" --&gt; <br />
</span>
&lt;!--#else--&gt;<br />
<span class="indent">
&lt;!--#set var="IMG_Apache" value="http://$SERVER_NAME:$SERVER_PORT/icons/apache_pb.gif" --&gt;<br />
</span>
&lt;!--#endif--&gt;<br />
<br />

&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"&gt; <br />
&lt;html&gt; <br />
&lt;head&gt; <br />
  <span class="indent">
  &lt;title&gt; <br />
  [&lt;!--#echo var="REDIRECT_STATUS" --&gt;] &lt;!--#echo var="title" --&gt; <br />
  &lt;/title&gt; <br />
  </span>
&lt;/head&gt; <br />
<br />
&lt;body bgcolor="white" background="&lt;!--#echo var="IMG_BgImage" --&gt;"&gt; <br />
<span class="indent">
  &lt;h1 align="center"&gt; <br />
  [&lt;!--#echo var="REDIRECT_STATUS" --&gt;] 
  &lt;!--#echo var="title" --&gt; <br />
  &lt;img src="&lt;!--#echo var="IMG_CorpLogo" --&gt;" <br />
  &nbsp;&nbsp;alt="&lt;!--#echo var="ALT_CorpLogo" --&gt;" align="right"&gt; <br />
  &lt;/h1&gt; <br />
<br />
  &lt;hr /&gt;
  &lt;!-- ======================================================== --&gt; <br />
  &lt;div&gt;
</span>
</code></p></div>

    <p>and this is the <code>foot.shtml.en</code> file:</p>

<div class="example"><p><code>
<span class="indent">
  &lt;/div&gt; <br />
  &lt;hr /&gt; <br />
  <br />
  &lt;div align="right"&gt; <br />
  <span class="indent">
  &lt;small&gt;Local Server time:
  &lt;!--#echo var="DATE_LOCAL" --&gt;&lt;/small&gt; <br />
  </span>
  &lt;/div&gt; <br />
  <br />
  &lt;div align="center"&gt;<br />
  <span class="indent">
    &lt;a href="&lt;!--#echo var="DOC_Apache" --&gt;"&gt; <br />
    &lt;img src="&lt;!--#echo var="IMG_Apache" --&gt;" border="0" align="bottom" <br />
    &nbsp;&nbsp;alt="Powered by &lt;!--#echo var="SERVER_SOFTWARE" --&gt;"&gt;&lt;/a&gt; <br />
  &lt;br /&gt;<br />

  &lt;small&gt;&lt;!--#set var="var" value="Powered by $SERVER_SOFTWARE -- <br />
  File last modified on $LAST_MODIFIED" --&gt; <br />
  &lt;!--#echo var="var" --&gt;&lt;/small&gt; <br />
  </span>
  &lt;/div&gt; <br />
  <br />
  &lt;p&gt;If the indicated error looks like a misconfiguration, please inform <br />
  &lt;a href="mailto:&lt;!--#echo var="SERVER_ADMIN" --&gt;" <br />
  subject="Feedback about Error message [&lt;!--#echo var="REDIRECT_STATUS" --&gt;] <br />
  &lt;!--#echo var="title" --&gt;, req=&lt;!--#echo var="REQUEST_URI" --&gt;"&gt; <br />
  &lt;!--#echo var="SERVER_NAME" --&gt;'s WebMaster&lt;/a&gt;.<br />
  &lt;/p&gt;<br />
  </span>
<br />
&lt;/body&gt;<br />
&lt;/html&gt;
</code></p></div>

    <p>If you have tips to contribute, send mail to <a href="mailto:martin@apache.org">martin@apache.org</a></p>
  </div></div>
<div class="bottomlang">
<p><span>Available Languages: </span><a href="../en/misc/custom_errordocs.html" title="English">&nbsp;en&nbsp;</a></p>
</div><div id="footer">
<p class="apache">Copyright 2006 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>
<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>
</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -