home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / apache_2.2.8-win32-x86-no_ssl.msi / Data1.cab / _FAB064E4B3E376B221B58B4EABAB0AED < prev    next >
Extensible Markup Language  |  2007-09-01  |  22KB  |  387 lines

  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>mod_headers - 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>
  14. <div id="page-header">
  15. <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>
  16. <p class="apache">Apache HTTP Server Version 2.2</p>
  17. <img alt="" src="../images/feather.gif" /></div>
  18. <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
  19. <div id="path">
  20. <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> > <a href="./">Modules</a></div>
  21. <div id="page-content">
  22. <div id="preamble"><h1>Apache Module mod_headers</h1>
  23. <div class="toplang">
  24. <p><span>Available Languages: </span><a href="../en/mod/mod_headers.html" title="English"> en </a> |
  25. <a href="../ja/mod/mod_headers.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
  26. <a href="../ko/mod/mod_headers.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p>
  27. </div>
  28. <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Customization of HTTP request and response
  29. headers</td></tr>
  30. <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr>
  31. <tr><th><a href="module-dict.html#ModuleIdentifier">ModuleáIdentifier:</a></th><td>headers_module</td></tr>
  32. <tr><th><a href="module-dict.html#SourceFile">SourceáFile:</a></th><td>mod_headers.c</td></tr>
  33. <tr><th><a href="module-dict.html#Compatibility">Compatibility:</a></th><td><code class="directive"><a href="#requestheader">RequestHeader</a></code>
  34. is available only in Apache 2.0</td></tr></table>
  35. <h3>Summary</h3>
  36.  
  37.     <p>This module provides directives to control and modify HTTP
  38.     request and response headers. Headers can be merged, replaced
  39.     or removed.</p>
  40. </div>
  41. <div id="quickview"><h3 class="directives">Directives</h3>
  42. <ul id="toc">
  43. <li><img alt="" src="../images/down.gif" /> <a href="#header">Header</a></li>
  44. <li><img alt="" src="../images/down.gif" /> <a href="#requestheader">RequestHeader</a></li>
  45. </ul>
  46. <h3>Topics</h3>
  47. <ul id="topics">
  48. <li><img alt="" src="../images/down.gif" /> <a href="#order">Order of Processing</a></li>
  49. <li><img alt="" src="../images/down.gif" /> <a href="#early">Early and Late Processing</a></li>
  50. <li><img alt="" src="../images/down.gif" /> <a href="#examples">Examples</a></li>
  51. </ul></div>
  52. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  53. <div class="section">
  54. <h2><a name="order" id="order">Order of Processing</a></h2>
  55.  
  56.     <p>The directives provided by <code class="module"><a href="../mod/mod_headers.html">mod_headers</a></code> can
  57.     occur almost anywhere within the server configuration, and can be
  58.     limited in scope by enclosing them in <a href="../sections.html">configuration sections</a>.</p>
  59.  
  60.     <p>Order of processing is important and is affected both by the
  61.     order in the configuration file and by placement in <a href="../sections.html#mergin">configuration sections</a>. These
  62.     two headers have a different effect if reversed:</p>
  63.  
  64.     <div class="example"><p><code>
  65.       RequestHeader append MirrorID "mirror 12"<br />
  66.       RequestHeader unset MirrorID
  67.     </code></p></div>
  68.  
  69.     <p>This way round, the <code>MirrorID</code> header is not set. If
  70.     reversed, the MirrorID header is set to "mirror 12".</p>
  71. </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  72. <div class="section">
  73. <h2><a name="early" id="early">Early and Late Processing</a></h2>
  74.     <p><code class="module"><a href="../mod/mod_headers.html">mod_headers</a></code> can be applied either early or late
  75.     in the request.  The normal mode is late, when Request Headers are
  76.     set immediately before running the content generator and Response
  77.     Headers just as the response is sent down the wire.  Always use
  78.     Late mode in an operational server.</p>
  79.  
  80.     <p>Early mode is designed as a test/debugging aid for developers.
  81.     Directives defined using the <code>early</code> keyword are set
  82.     right at the beginning of processing the request.  This means
  83.     they can be used to simulate different requests and set up test
  84.     cases, but it also means that headers may be changed at any time
  85.     by other modules before generating a Response.</p>
  86.  
  87.     <p>Because early directives are processed before the request path's
  88.     configuration is traversed, early headers can only be set in a
  89.     main server or virtual host context.  Early directives cannot depend
  90.     on a request path, so they will fail in contexts such as
  91.     <code><Directory></code> or <code><Location></code>.</p>
  92. </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  93. <div class="section">
  94. <h2><a name="examples" id="examples">Examples</a></h2>
  95.  
  96.     <ol>
  97.       <li>
  98.         Copy all request headers that begin with "TS" to the
  99.         response headers:
  100.  
  101.         <div class="example"><p><code>
  102.           Header echo ^TS
  103.         </code></p></div>
  104.       </li>
  105.  
  106.       <li>
  107.         Add a header, <code>MyHeader</code>, to the response including a
  108.         timestamp for when the request was received and how long it
  109.         took to begin serving the request. This header can be used by
  110.         the client to intuit load on the server or in isolating
  111.         bottlenecks between the client and the server.
  112.  
  113.         <div class="example"><p><code>
  114.           Header set MyHeader "%D %t"
  115.         </code></p></div>
  116.  
  117.         <p>results in this header being added to the response:</p>
  118.  
  119.         <div class="example"><p><code>
  120.           MyHeader: D=3775428 t=991424704447256
  121.         </code></p></div>
  122.       </li>
  123.  
  124.       <li>
  125.         Say hello to Joe
  126.  
  127.         <div class="example"><p><code>
  128.           Header set MyHeader "Hello Joe. It took %D microseconds \<br />
  129.           for Apache to serve this request."
  130.         </code></p></div>
  131.  
  132.         <p>results in this header being added to the response:</p>
  133.  
  134.         <div class="example"><p><code>
  135.           MyHeader: Hello Joe. It took D=3775428 microseconds for Apache
  136.           to serve this request.
  137.         </code></p></div>
  138.       </li>
  139.  
  140.       <li>
  141.         Conditionally send <code>MyHeader</code> on the response if and
  142.         only if header <code>MyRequestHeader</code> is present on the request.
  143.         This is useful for constructing headers in response to some client
  144.         stimulus. Note that this example requires the services of the
  145.         <code class="module"><a href="../mod/mod_setenvif.html">mod_setenvif</a></code> module.
  146.  
  147.         <div class="example"><p><code>
  148.           SetEnvIf MyRequestHeader myvalue HAVE_MyRequestHeader<br />
  149.           Header set MyHeader "%D %t mytext" env=HAVE_MyRequestHeader
  150.         </code></p></div>
  151.  
  152.         <p>If the header <code>MyRequestHeader: myvalue</code> is present on
  153.         the HTTP request, the response will contain the following header:</p>
  154.  
  155.         <div class="example"><p><code>
  156.           MyHeader: D=3775428 t=991424704447256 mytext
  157.         </code></p></div>
  158.       </li>
  159.  
  160.       <li>
  161.         Enable DAV to work with Apache running HTTP through SSL hardware
  162.         (<a href="http://svn.haxx.se/users/archive-2006-03/0549.shtml">problem
  163.         description</a>) by replacing <var>https:</var> with
  164.         <var>http:</var> in the <var>Destination</var> header:
  165.  
  166.         <div class="example"><p><code>
  167.           RequestHeader edit Destination ^https: http: early
  168.         </code></p></div>
  169.       </li>
  170.     </ol>
  171. </div>
  172. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  173. <div class="directive-section"><h2><a name="Header" id="Header">Header</a> <a name="header" id="header">Directive</a></h2>
  174. <table class="directive">
  175. <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Configure HTTP response headers</td></tr>
  176. <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>Header [<var>condition</var>] set|append|add|unset|echo|edit
  177. <var>header</var> [<var>value</var>] [early|env=[!]<var>variable</var>]</code></td></tr>
  178. <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
  179. <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
  180. <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
  181. <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_headers</td></tr>
  182. </table>
  183.     <p>This directive can replace, merge or remove HTTP response
  184.     headers. The header is modified just after the content handler
  185.     and output filters are run, allowing outgoing headers to be
  186.     modified.</p>
  187.  
  188.     <p>The optional <var>condition</var> can be either <code>onsuccess</code>
  189.     or <code>always</code>. It determines, which internal header table should be
  190.     operated on. <code>onsuccess</code> stands for <code>2<var>xx</var></code>
  191.     status codes and <code>always</code> for all status codes (including
  192.     <code>2<var>xx</var></code>). Especially if you want to unset headers
  193.     set by certain modules, you should try out, which table is affected.</p>
  194.  
  195.     <p>The action it performs is determined by the second
  196.     argument. This can be one of the following values:</p>
  197.  
  198.     <dl>
  199.     <dt><code>set</code></dt>
  200.     <dd>The response header is set, replacing any previous header
  201.     with this name. The <var>value</var> may be a format string.</dd>
  202.  
  203.     <dt><code>append</code></dt>
  204.     <dd>The response header is appended to any existing header of
  205.     the same name. When a new value is merged onto an existing
  206.     header it is separated from the existing header with a comma.
  207.     This is the HTTP standard way of giving a header multiple values.</dd>
  208.  
  209.     <dt><code>add</code></dt>
  210.     <dd>The response header is added to the existing set of headers,
  211.     even if this header already exists. This can result in two
  212.     (or more) headers having the same name. This can lead to
  213.     unforeseen consequences, and in general <code>set</code> or
  214.     <code>append</code> should be used instead.</dd>
  215.  
  216.     <dt><code>unset</code></dt>
  217.     <dd>The response header of this name is removed, if it exists.
  218.     If there are multiple headers of the same name, all will be
  219.     removed. <var>value</var> must be omitted.</dd>
  220.  
  221.     <dt><code>echo</code></dt>
  222.     <dd>Request headers with this name are echoed back in the
  223.     response headers. <var>header</var> may be a
  224.     <a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular expression</a>.
  225.     <var>value</var> must be omitted.</dd>
  226.  
  227.     <dt><code>edit</code></dt>
  228.     <dd>If this request header exists, its value is transformed according
  229.     to a <a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular expression</a>
  230.     search-and-replace.  The <var>value</var> argument is a <a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular expression</a>, and the <var>replacement</var>
  231.     is a replacement string, which may contain backreferences.</dd>
  232.     </dl>
  233.  
  234.     <p>This argument is followed by a <var>header</var> name, which
  235.     can include the final colon, but it is not required. Case is
  236.     ignored for <code>set</code>, <code>append</code>, <code>add</code>,
  237.     <code>unset</code>, and <code>edit</code>.
  238.     The <var>header</var> name for <code>echo</code>
  239.     is case sensitive and may be a <a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular
  240.     expression</a>.</p>
  241.  
  242.     <p>For <code>set</code>, <code>append</code> and <code>add</code> a
  243.     <var>value</var> is specified as the third argument. If <var>value</var>
  244.     contains spaces, it should be surrounded by double quotes.
  245.     <var>value</var> may be a character string, a string containing format
  246.     specifiers or a combination of both. The following format specifiers
  247.     are supported in <var>value</var>:</p>
  248.  
  249.     <table class="bordered"><tr class="header"><th>Format</th><th>Description</th></tr>
  250. <tr><td><code>%%</code></td>
  251.         <td>The percent sign</td></tr>
  252. <tr class="odd"><td><code>%t</code></td>
  253.         <td>The time the request was received in Universal Coordinated Time
  254.         since the epoch (Jan. 1, 1970) measured in microseconds. The value
  255.         is preceded by <code>t=</code>.</td></tr>
  256. <tr><td><code>%D</code></td>
  257.         <td>The time from when the request was received to the time the
  258.         headers are sent on the wire. This is a measure of the duration
  259.         of the request. The value is preceded by <code>D=</code>.</td></tr>
  260. <tr class="odd"><td><code>%{FOOBAR}e</code></td>
  261.         <td>The contents of the <a href="../env.html">environment
  262.         variable</a> <code>FOOBAR</code>.</td></tr>
  263. <tr><td><code>%{FOOBAR}s</code></td>
  264.         <td>The contents of the <a href="mod_ssl.html#envvars">SSL environment
  265.         variable</a> <code>FOOBAR</code>, if <code class="module"><a href="../mod/mod_ssl.html">mod_ssl</a></code> is enabled.</td></tr>
  266. </table>
  267.  
  268.     <div class="note"><h3>Note</h3>
  269.       <p>The <code>%s</code> format specifier is only available in
  270.       Apache 2.1 and later; it can be used instead of <code>%e</code>
  271.       to avoid the overhead of enabling <code>SSLOptions
  272.       +StdEnvVars</code>.  If <code>SSLOptions +StdEnvVars</code> must
  273.       be enabled anyway for some other reason, <code>%e</code> will be
  274.       more efficient than <code>%s</code>.</p>
  275.     </div>
  276.  
  277.     <p>For <code>edit</code> there is both a <var>value</var> argument
  278.     which is a <a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular expression</a>,
  279.     and an additional <var>replacement</var> string.</p>
  280.  
  281.     <p>The <code class="directive">Header</code> directive may be followed by an
  282.     an additional argument, which may be used to specify conditions under
  283.     which the action will be taken, or may be the keyword <code>early</code>
  284.     to specify <a href="#early">early processing</a>. If the
  285.     <a href="../env.html">environment variable</a> specified in the
  286.     <code>env=<var>...</var></code> argument exists (or if the environment
  287.     variable does not exist and <code>env=!<var>...</var></code> is specified)
  288.     then the action specified by the <code class="directive">Header</code> directive
  289.     will take effect. Otherwise, the directive will have no effect
  290.     on the request.</p>
  291.  
  292.     <p>Except in <a href="#early">early</a> mode, the
  293.     <code class="directive">Header</code> directives are processed just
  294.     before the response is sent to the network. These means that it is
  295.     possible to set and/or override most headers, except for those headers
  296.     added by the header filter.</p>
  297.  
  298. </div>
  299. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  300. <div class="directive-section"><h2><a name="RequestHeader" id="RequestHeader">RequestHeader</a> <a name="requestheader" id="requestheader">Directive</a></h2>
  301. <table class="directive">
  302. <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Configure HTTP request headers</td></tr>
  303. <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RequestHeader set|append|add|unset|edit <var>header</var>
  304. [<var>value</var>] [<var>replacement</var>] [early|env=[!]<var>variable</var>]</code></td></tr>
  305. <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
  306. <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
  307. <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
  308. <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_headers</td></tr>
  309. </table>
  310.     <p>This directive can replace, merge, change or remove HTTP request
  311.     headers. The header is modified just before the content handler
  312.     is run, allowing incoming headers to be modified. The action it
  313.     performs is determined by the first argument. This can be one
  314.     of the following values:</p>
  315.  
  316.     <dl>
  317.     <dt><code>set</code></dt>
  318.     <dd>The request header is set, replacing any previous header
  319.     with this name</dd>
  320.  
  321.     <dt><code>append</code></dt>
  322.     <dd>The request header is appended to any existing header of the
  323.     same name. When a new value is merged onto an existing header
  324.     it is separated from the existing header with a comma. This
  325.     is the HTTP standard way of giving a header multiple
  326.     values.</dd>
  327.  
  328.     <dt><code>add</code></dt>
  329.     <dd>The request header is added to the existing set of headers,
  330.     even if this header already exists. This can result in two
  331.     (or more) headers having the same name. This can lead to
  332.     unforeseen consequences, and in general <code>set</code> or
  333.     <code>append</code> should be used instead.</dd>
  334.  
  335.     <dt><code>unset</code></dt>
  336.     <dd>The request header of this name is removed, if it exists. If
  337.     there are multiple headers of the same name, all will be removed.
  338.     <var>value</var> must be omitted.</dd>
  339.  
  340.     <dt><code>edit</code></dt>
  341.     <dd>If this request header exists, its value is transformed according
  342.     to a <a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular expression</a>
  343.     search-and-replace.  The <var>value</var> argument is a <a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular expression</a>, and the <var>replacement</var>
  344.     is a replacement string, which may contain backreferences.</dd>
  345.     </dl>
  346.  
  347.     <p>This argument is followed by a header name, which can
  348.     include the final colon, but it is not required. Case is
  349.     ignored. For <code>set</code>, <code>append</code> and
  350.     <code>add</code> a <var>value</var> is given as the third argument. If a
  351.     <var>value</var> contains spaces, it should be surrounded by double
  352.     quotes. For <code>unset</code>, no <var>value</var> should be given.
  353.     <var>value</var> may be a character string, a string containing format
  354.     specifiers or a combination of both. The supported format specifiers
  355.     are the same as for the <code class="directive"><a href="#header">Header</a></code>,
  356.     please have a look there for details.  For <code>edit</code> both
  357.     a <var>value</var> and a <var>replacement</var> are required, and are
  358.     a <a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular expression</a> and a
  359.     replacement string respectively.</p>
  360.  
  361.     <p>The <code class="directive">RequestHeader</code> directive may be followed by
  362.     an additional argument, which may be used to specify conditions under
  363.     which the action will be taken, or may be the keyword <code>early</code>
  364.     to specify <a href="#early">early processing</a>. If the
  365.     <a href="../env.html">environment
  366.     variable</a> specified in the <code>env=<var>...</var></code> argument
  367.     exists (or if the environment variable does not exist and
  368.     <code>env=!<var>...</var></code> is specified) then the action specified
  369.     by the <code class="directive">RequestHeader</code> directive will take effect.
  370.     Otherwise, the directive will have no effect on the request.</p>
  371.  
  372.     <p>Except in <a href="#early">early</a> mode, the
  373.     <code class="directive">RequestHeader</code> directive is processed
  374.     just before the request is run by its handler in the fixup phase.
  375.     This should allow headers generated by the browser, or by Apache
  376.     input filters to be overridden or modified.</p>
  377.  
  378. </div>
  379. </div>
  380. <div class="bottomlang">
  381. <p><span>Available Languages: </span><a href="../en/mod/mod_headers.html" title="English"> en </a> |
  382. <a href="../ja/mod/mod_headers.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
  383. <a href="../ko/mod/mod_headers.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p>
  384. </div><div id="footer">
  385. <p class="apache">Copyright 2007 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>
  386. <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>
  387. </body></html>