mod_headers.html revision 35f745d0d98970c673c5ef89cd48bbd2beeb2efe
effcbdb12c7ef892f1fd92a745cb33a08ca4ba30Stephen Gallagher<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
effcbdb12c7ef892f1fd92a745cb33a08ca4ba30Stephen Gallagher<!--#include virtual="header.html" -->
effcbdb12c7ef892f1fd92a745cb33a08ca4ba30Stephen GallagherThe optional headers module allows for the customization of HTTP
effcbdb12c7ef892f1fd92a745cb33a08ca4ba30Stephen Gallagherresponse headers. Headers can be merged, replaced or removed. The
effcbdb12c7ef892f1fd92a745cb33a08ca4ba30Stephen Gallagherdirectives described in this document are only available if Apache is
74e95cfd9d3939dfe9417d79d2f6fc79b361405fJakub Hrozek<strong>Syntax:</strong> Header [ set | append | add ] <em>header</em> <em>value</em><br>
effcbdb12c7ef892f1fd92a745cb33a08ca4ba30Stephen Gallagher<strong>Syntax:</strong> Header unset <em>header</em><br>
55d80b1301fe969fb4ba2b9481027887b9462dbbJakub Hrozek<strong>Context:</strong> server config, virtual host, access.conf, .htaccess<br>
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub HrozekThis directive can replace, merge or remove HTTP response headers. The
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozekaction it performs is determined by the first argument. This can be one
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozekof the following values:
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozek The response header is set, replacing any previous header with this name
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozek The response header is appended to any existing header of the same
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozek name. When a new value is merged onto an existing header it is
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozek separated from the existing header with a comma. This is the HTTP standard
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozek way of giving a header multiple values.
90afedb00608547ae1f32aa7aafd552c4b306909Jakub Hrozek The response header is added to the existing set of headers, even if
90afedb00608547ae1f32aa7aafd552c4b306909Jakub Hrozek this header already exists. This can result in two (or more) headers
90afedb00608547ae1f32aa7aafd552c4b306909Jakub Hrozek having the same name. This can lead to unforeseen consequences, and in
90afedb00608547ae1f32aa7aafd552c4b306909Jakub Hrozek general "append" should be used instead.
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozek The response header of this name is removed, if it exists. If there are
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozek multiple headers of the same name, only the first one set will be removed.
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub HrozekThis argument is followed by a header name, which can include the
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozekfinal colon, but it is not required. Case is ignored. For
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozekadd, append and set a value is given as the third argument. If this
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozekvalue contains spaces, it should be surrounded by double quotes.
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub HrozekFor unset, no value should be given.
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub HrozekThe Header directive can occur almost anywhere within the server
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozekconfiguration. It is valid in the main server config and virtual host
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozeksections, inside <Directory>, <Location> and <Files>
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozeksections, and within .htaccess files.
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub HrozekThe Header directives are processed in the following order:
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozek<li>main server
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozek<li>virtual host
35d420c5d4609b6e999920e38a9b2ec40a0e1ac4Jakub Hrozek<li><Directory> sections and .htaccess
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozek<li><Location>
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozek<li><Files>
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub HrozekOrder is important. These two headers have a different effect if reversed:
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub HrozekHeader append Author "John P. Doe"
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub HrozekHeader unset Author
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub HrozekThis way round, the Author header is not set. If reversed, the Author
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozekheader is set to "John P. Doe".
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub HrozekThe Header directives are processed just before the response is sent
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozekby its handler. These means that some headers that are added just
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozekbefore the response is sent cannot be unset or overridden. This
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozekincludes headers such as "Date" and "Server".
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozek<!--#include virtual="footer.html" -->