mod_headers.html revision d030d579df50673f566f5dbcd1904fd59cd310e0
02c335c23bf5fa225a467c19f2c063fb0dc7b8c3Timo Sirainen<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen<HTML>
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen<HEAD>
c7713320cd35e77543f1bdc7229988a160dae322Timo Sirainen<TITLE>Apache module mod_headers</TITLE>
27bb267255b36d34c638c34a1ade611962f00772Timo Sirainen</HEAD>
c7713320cd35e77543f1bdc7229988a160dae322Timo Sirainen
c7713320cd35e77543f1bdc7229988a160dae322Timo Sirainen<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen<BODY
eba7f36feec8d02c4c394e55ff4effd47e33d311Timo Sirainen BGCOLOR="#FFFFFF"
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen TEXT="#000000"
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen LINK="#0000FF"
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen VLINK="#000080"
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen ALINK="#FF0000"
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen>
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen<!--#include virtual="header.html" -->
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen<H1 ALIGN="CENTER">Module mod_headers</H1>
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen
169b1488b6eea7a968021afa4f929b2e26d75d98Timo SirainenThe optional headers module allows for the customization of HTTP
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainenresponse headers. Headers can be merged, replaced or removed. The
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainendirectives described in this document are only available if Apache is
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainencompiled with <STRONG>mod_headers.c</STRONG>.
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen<HR>
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen<H2>Directive</H2>
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen<UL>
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen<LI><A HREF="#header">Header</A>
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen</UL>
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen<HR>
2a325b952fe47346d76221d2c07a3fe02faf8800Timo Sirainen
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen<H2><A NAME="header">Header</A></H2>
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen<A
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen HREF="directive-dict.html#Syntax"
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen REL="Help"
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen><STRONG>Syntax:</STRONG></A> Header [ set | append | add ]
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen <EM>header</EM> <EM>value</EM><BR>
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen<A
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen HREF="directive-dict.html#Syntax"
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen REL="Help"
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen><STRONG>Syntax:</STRONG></A> Header unset <EM>header</EM><BR>
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen<A
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen HREF="directive-dict.html#Context"
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen REL="Help"
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen><STRONG>Context:</STRONG></A> server config, virtual host, access.conf,
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen .htaccess<BR>
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen<A
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen HREF="directive-dict.html#Status"
4307c886579381dbb1897ea1388ae6978c96f560Timo Sirainen REL="Help"
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen><STRONG>Status:</STRONG></A> optional<BR>
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen<A
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen HREF="directive-dict.html#Module"
bf333c7645b8ddb6eedd6834db2fd908888793e1Timo Sirainen REL="Help"
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen><STRONG>Module:</STRONG></A> mod_header<P>
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen
169b1488b6eea7a968021afa4f929b2e26d75d98Timo SirainenThis directive can replace, merge or remove HTTP response headers. The
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainenaction it performs is determined by the first argument. This can be one
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainenof the following values:
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen<UL>
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen<LI><STRONG>set</STRONG><BR>
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen The response header is set, replacing any previous header with this name
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen<LI><STRONG>append</STRONG><BR>
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen The response header is appended to any existing header of the same
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen name. When a new value is merged onto an existing header it is
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen separated from the existing header with a comma. This is the HTTP standard
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen way of giving a header multiple values.
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen<LI><STRONG>add</STRONG><BR>
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen The response header is added to the existing set of headers, even if
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen this header already exists. This can result in two (or more) headers
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen having the same name. This can lead to unforeseen consequences, and in
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen general "append" should be used instead.
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen<LI><STRONG>unset</STRONG><BR>
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen The response header of this name is removed, if it exists. If there are
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen multiple headers of the same name, only the first one set will be removed.
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen</UL>
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen
169b1488b6eea7a968021afa4f929b2e26d75d98Timo SirainenThis argument is followed by a header name, which can include the
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainenfinal colon, but it is not required. Case is ignored. For
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainenadd, append and set a value is given as the third argument. If this
bf333c7645b8ddb6eedd6834db2fd908888793e1Timo Sirainenvalue contains spaces, it should be surrounded by double quotes.
169b1488b6eea7a968021afa4f929b2e26d75d98Timo SirainenFor unset, no value should be given.
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen<H3>Order of Processing</H3>
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen
bf333c7645b8ddb6eedd6834db2fd908888793e1Timo SirainenThe Header directive can occur almost anywhere within the server
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainenconfiguration. It is valid in the main server config and virtual host
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainensections, inside &lt;Directory&gt;, &lt;Location&gt; and &lt;Files&gt;
7237f2f0a577413e12662228ee2039425fd2f5b0Timo Sirainensections, and within .htaccess files.
c7713320cd35e77543f1bdc7229988a160dae322Timo Sirainen<P>
7237f2f0a577413e12662228ee2039425fd2f5b0Timo SirainenThe Header directives are processed in the following order:
c7713320cd35e77543f1bdc7229988a160dae322Timo Sirainen<OL>
c7713320cd35e77543f1bdc7229988a160dae322Timo Sirainen<LI>main server
7237f2f0a577413e12662228ee2039425fd2f5b0Timo Sirainen<LI>virtual host
c7713320cd35e77543f1bdc7229988a160dae322Timo Sirainen<LI>&lt;Directory&gt; sections and .htaccess
c7713320cd35e77543f1bdc7229988a160dae322Timo Sirainen<LI>&lt;Location&gt;
c7713320cd35e77543f1bdc7229988a160dae322Timo Sirainen<LI>&lt;Files&gt;
c7713320cd35e77543f1bdc7229988a160dae322Timo Sirainen</OL>
7237f2f0a577413e12662228ee2039425fd2f5b0Timo Sirainen
7237f2f0a577413e12662228ee2039425fd2f5b0Timo SirainenOrder is important. These two headers have a different effect if reversed:
7237f2f0a577413e12662228ee2039425fd2f5b0Timo Sirainen<PRE>
7237f2f0a577413e12662228ee2039425fd2f5b0Timo SirainenHeader append Author "John P. Doe"
7237f2f0a577413e12662228ee2039425fd2f5b0Timo SirainenHeader unset Author
7237f2f0a577413e12662228ee2039425fd2f5b0Timo Sirainen</PRE>
7237f2f0a577413e12662228ee2039425fd2f5b0Timo Sirainen
27bb267255b36d34c638c34a1ade611962f00772Timo SirainenThis way round, the Author header is not set. If reversed, the Author
27bb267255b36d34c638c34a1ade611962f00772Timo Sirainenheader is set to "John P. Doe".
27bb267255b36d34c638c34a1ade611962f00772Timo Sirainen<P>
27bb267255b36d34c638c34a1ade611962f00772Timo Sirainen
27bb267255b36d34c638c34a1ade611962f00772Timo SirainenThe Header directives are processed just before the response is sent
27bb267255b36d34c638c34a1ade611962f00772Timo Sirainenby its handler. These means that some headers that are added just
27bb267255b36d34c638c34a1ade611962f00772Timo Sirainenbefore the response is sent cannot be unset or overridden. This
27bb267255b36d34c638c34a1ade611962f00772Timo Sirainenincludes headers such as "Date" and "Server".
27bb267255b36d34c638c34a1ade611962f00772Timo Sirainen<P>
27bb267255b36d34c638c34a1ade611962f00772Timo Sirainen
27bb267255b36d34c638c34a1ade611962f00772Timo Sirainen<!--#include virtual="footer.html" -->
27bb267255b36d34c638c34a1ade611962f00772Timo Sirainen</BODY>
27bb267255b36d34c638c34a1ade611962f00772Timo Sirainen</HTML>
27bb267255b36d34c638c34a1ade611962f00772Timo Sirainen