mod_headers.html revision 1997e02bed99bd0c081962ade257a0ea12ebe15b
c313914d0e66b20969215e519bbf2ab4ecf39512Tinderbox User<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
c80e152862cc3e3207dc837fde7116bd4c0e4b9dTinderbox User<HTML>
c80e152862cc3e3207dc837fde7116bd4c0e4b9dTinderbox User<HEAD>
8d1b3ceb4d491ce32572f1702f37ed585eede993Evan Hunt<TITLE>Apache module mod_headers</TITLE>
8d1b3ceb4d491ce32572f1702f37ed585eede993Evan Hunt</HEAD>
d77cb075aae5595e460e3299bfc1e8ea5d42b560Evan Hunt
d77cb075aae5595e460e3299bfc1e8ea5d42b560Evan Hunt<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
30ca20f720ad0887772a79e7abb25b4fa0e4b5b0Mark Andrews<BODY
30ca20f720ad0887772a79e7abb25b4fa0e4b5b0Mark Andrews BGCOLOR="#FFFFFF"
30ca20f720ad0887772a79e7abb25b4fa0e4b5b0Mark Andrews TEXT="#000000"
30ca20f720ad0887772a79e7abb25b4fa0e4b5b0Mark Andrews LINK="#0000FF"
30ca20f720ad0887772a79e7abb25b4fa0e4b5b0Mark Andrews VLINK="#000080"
701a93f5a592e4652343e049aa495d409c3ee133Mark Andrews ALINK="#FF0000"
7ec97ae74e42ec21b354fd2d1366313b41d947d6Evan Hunt>
701a93f5a592e4652343e049aa495d409c3ee133Mark Andrews<!--#include virtual="header.html" -->
701a93f5a592e4652343e049aa495d409c3ee133Mark Andrews<H1 ALIGN="CENTER">Module mod_headers</H1>
002f1373374a0b72fc0329baa682917929bef168Tony Finch
002f1373374a0b72fc0329baa682917929bef168Tony Finch<p>This module provides for the customization of HTTP
8f1ed05dc0aae7ae6c3da6ec6d405df61257a61eMark Andrewsresponse headers.</p>
8f1ed05dc0aae7ae6c3da6ec6d405df61257a61eMark Andrews
8f1ed05dc0aae7ae6c3da6ec6d405df61257a61eMark Andrews<P><A
8f1ed05dc0aae7ae6c3da6ec6d405df61257a61eMark AndrewsHREF="module-dict.html#Status"
8f1ed05dc0aae7ae6c3da6ec6d405df61257a61eMark AndrewsREL="Help"
73cf0ba4e82c6baef638ecc4e31321223f841d28Mark Andrews><STRONG>Status:</STRONG></A> Extension
73cf0ba4e82c6baef638ecc4e31321223f841d28Mark Andrews<BR>
73cf0ba4e82c6baef638ecc4e31321223f841d28Mark Andrews<A
d8351dfc9b725b0d727be7acab6247d7d501d9a0Mark AndrewsHREF="module-dict.html#SourceFile"
d8351dfc9b725b0d727be7acab6247d7d501d9a0Mark AndrewsREL="Help"
d8351dfc9b725b0d727be7acab6247d7d501d9a0Mark Andrews><STRONG>Source File:</STRONG></A> mod_headers.c
3a29ce9c08dd31709c73e7187aebda0d360c537bEvan Hunt<BR>
3a29ce9c08dd31709c73e7187aebda0d360c537bEvan Hunt<A
5c78f1f50e53d8e2ed51a187efc2c9a0f43b4b1bMark AndrewsHREF="module-dict.html#ModuleIdentifier"
f1740da065d4555039fe8bb53beb4153e3f94de3Mark AndrewsREL="Help"
f1740da065d4555039fe8bb53beb4153e3f94de3Mark Andrews><STRONG>Module Identifier:</STRONG></A> headers_module
f1740da065d4555039fe8bb53beb4153e3f94de3Mark Andrews<BR>
31c7ab4fb3f7710af87dc9c3d64c5daf9a3dea35Mark Andrews<A
31c7ab4fb3f7710af87dc9c3d64c5daf9a3dea35Mark AndrewsHREF="module-dict.html#Compatibility"
31c7ab4fb3f7710af87dc9c3d64c5daf9a3dea35Mark AndrewsREL="Help"
31c7ab4fb3f7710af87dc9c3d64c5daf9a3dea35Mark Andrews><STRONG>Compatibility:</STRONG></A> Available in Apache 1.2 and later.
31c7ab4fb3f7710af87dc9c3d64c5daf9a3dea35Mark Andrews</P>
ad309e8dfa0601d6053aaa12770a98a6940f89deEvan Hunt
ad309e8dfa0601d6053aaa12770a98a6940f89deEvan Hunt<h2>Summary</h2>
635e4351b04fd61ca6d853bdac6268c090b55129Mark Andrews
635e4351b04fd61ca6d853bdac6268c090b55129Mark AndrewsThis module provides a directive to control the sending of HTTP
fc04365d2f83f197c8a54545dd9cd4ce6a209940Mark Andrewsheaders. Headers can be merged, replaced or removed.
fc04365d2f83f197c8a54545dd9cd4ce6a209940Mark Andrews
7cbac360bf98c0a52b2d6866ad887616c32d4d3aMark Andrews<H2>Directives</H2>
7cbac360bf98c0a52b2d6866ad887616c32d4d3aMark Andrews<UL>
7cbac360bf98c0a52b2d6866ad887616c32d4d3aMark Andrews<LI><A HREF="#header">Header</A>
1cf118a656f5fd210787908b845362077fc507f8Evan Hunt</UL>
1cf118a656f5fd210787908b845362077fc507f8Evan Hunt
1cf118a656f5fd210787908b845362077fc507f8Evan Hunt<HR>
1cf118a656f5fd210787908b845362077fc507f8Evan Hunt
1cf118a656f5fd210787908b845362077fc507f8Evan Hunt<H2><A NAME="header">Header</A> directive</H2>
1cf118a656f5fd210787908b845362077fc507f8Evan Hunt<A
1cf118a656f5fd210787908b845362077fc507f8Evan Hunt HREF="directive-dict.html#Syntax"
1cf118a656f5fd210787908b845362077fc507f8Evan Hunt REL="Help"
6fb3db01acad7f5c1f4e23789fb0f2ce56cc07deMukund Sivaraman><STRONG>Syntax:</STRONG></A> Header set|append|add
6fb3db01acad7f5c1f4e23789fb0f2ce56cc07deMukund Sivaraman <EM>header</EM> <EM>value</EM><BR>
6fb3db01acad7f5c1f4e23789fb0f2ce56cc07deMukund Sivaraman<A
fd82c70695888c134287b8018296028c252d100eMukund Sivaraman HREF="directive-dict.html#Syntax"
fd82c70695888c134287b8018296028c252d100eMukund Sivaraman REL="Help"
fd82c70695888c134287b8018296028c252d100eMukund Sivaraman><STRONG>Syntax:</STRONG></A> Header unset <EM>header</EM><BR>
fd82c70695888c134287b8018296028c252d100eMukund Sivaraman<A
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews HREF="directive-dict.html#Context"
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews REL="Help"
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews><STRONG>Context:</STRONG></A> server config, virtual host, access.conf,
2cf0fe3b8092f64f8f68ae3693fe2e73e90ad1a4Mark Andrews .htaccess<BR>
2cf0fe3b8092f64f8f68ae3693fe2e73e90ad1a4Mark Andrews<A
2cf0fe3b8092f64f8f68ae3693fe2e73e90ad1a4Mark Andrews HREF="directive-dict.html#Override"
2cf0fe3b8092f64f8f68ae3693fe2e73e90ad1a4Mark Andrews REL="Help"
4221d9cd1d02311fbf9b5f08a038f5af78b10b4aEvan Hunt><STRONG>Override:</STRONG></A> FileInfo<BR>
4221d9cd1d02311fbf9b5f08a038f5af78b10b4aEvan Hunt<A
4221d9cd1d02311fbf9b5f08a038f5af78b10b4aEvan Hunt HREF="directive-dict.html#Status"
4221d9cd1d02311fbf9b5f08a038f5af78b10b4aEvan Hunt REL="Help"
4221d9cd1d02311fbf9b5f08a038f5af78b10b4aEvan Hunt><STRONG>Status:</STRONG></A> Extension<BR>
f9c410d93711fbf312a0162f1e2d3f2a5ede69afFrancis Dupont<A
f9c410d93711fbf312a0162f1e2d3f2a5ede69afFrancis Dupont HREF="directive-dict.html#Module"
f9c410d93711fbf312a0162f1e2d3f2a5ede69afFrancis Dupont REL="Help"
f9c410d93711fbf312a0162f1e2d3f2a5ede69afFrancis Dupont><STRONG>Module:</STRONG></A> mod_header<P>
e526027287b849f0b6ab6e069156697cbafa22c1Michał Kępień
e526027287b849f0b6ab6e069156697cbafa22c1Michał KępieńThis directive can replace, merge or remove HTTP response headers. The
e526027287b849f0b6ab6e069156697cbafa22c1Michał Kępieńaction it performs is determined by the first argument. This can be one
e526027287b849f0b6ab6e069156697cbafa22c1Michał Kępieńof the following values:
929329d2d66a7e1083c70a9c918381935bf12799Mukund Sivaraman
929329d2d66a7e1083c70a9c918381935bf12799Mukund Sivaraman<UL>
929329d2d66a7e1083c70a9c918381935bf12799Mukund Sivaraman<LI><STRONG>set</STRONG><BR>
7e1a62eea2e4ba9d6c3fc718e679b965fa514f69Mark Andrews The response header is set, replacing any previous header with this name
ec29d217ba3a2bf3e617a7b5b6708ae221bee999Mark Andrews
ec29d217ba3a2bf3e617a7b5b6708ae221bee999Mark Andrews<LI><STRONG>append</STRONG><BR>
afefd754734f896bf3e0590177fff83e7cdfdf35Mark Andrews The response header is appended to any existing header of the same
afefd754734f896bf3e0590177fff83e7cdfdf35Mark Andrews name. When a new value is merged onto an existing header it is
afefd754734f896bf3e0590177fff83e7cdfdf35Mark Andrews separated from the existing header with a comma. This is the HTTP standard
f0353a586c2bfbae999193cb644b6bc94c7944d8Mark Andrews way of giving a header multiple values.
f0353a586c2bfbae999193cb644b6bc94c7944d8Mark Andrews
7ff28f5befbee76048a23e504dcd3f9a44ce6209Evan Hunt<LI><STRONG>add</STRONG><BR>
7ff28f5befbee76048a23e504dcd3f9a44ce6209Evan Hunt The response header is added to the existing set of headers, even if
7ff28f5befbee76048a23e504dcd3f9a44ce6209Evan Hunt this header already exists. This can result in two (or more) headers
7ff28f5befbee76048a23e504dcd3f9a44ce6209Evan Hunt having the same name. This can lead to unforeseen consequences, and in
7ff28f5befbee76048a23e504dcd3f9a44ce6209Evan Hunt general "append" should be used instead.
7ff28f5befbee76048a23e504dcd3f9a44ce6209Evan Hunt
7ff28f5befbee76048a23e504dcd3f9a44ce6209Evan Hunt<LI><STRONG>unset</STRONG><BR>
7ff28f5befbee76048a23e504dcd3f9a44ce6209Evan Hunt The response header of this name is removed, if it exists. If there are
7ff28f5befbee76048a23e504dcd3f9a44ce6209Evan Hunt multiple headers of the same name, all will be removed.
7ff28f5befbee76048a23e504dcd3f9a44ce6209Evan Hunt</UL>
cad79077bd5b2616bc4a7a6b3cbc0953bef8917fMark Andrews
cad79077bd5b2616bc4a7a6b3cbc0953bef8917fMark AndrewsThis argument is followed by a header name, which can include the
cad79077bd5b2616bc4a7a6b3cbc0953bef8917fMark Andrewsfinal colon, but it is not required. Case is ignored. For
cad79077bd5b2616bc4a7a6b3cbc0953bef8917fMark Andrewsadd, append and set a value is given as the third argument. If this
adfe58e8e5cd1890585e92b67f1fd01989a1fa7dMark Andrewsvalue contains spaces, it should be surrounded by double quotes.
adfe58e8e5cd1890585e92b67f1fd01989a1fa7dMark AndrewsFor unset, no value should be given.
adfe58e8e5cd1890585e92b67f1fd01989a1fa7dMark Andrews
c3237dec879f82855403ff7e3ba87b298172efd5Mark Andrews<H3>Order of Processing</H3>
c3237dec879f82855403ff7e3ba87b298172efd5Mark Andrews
c3237dec879f82855403ff7e3ba87b298172efd5Mark AndrewsThe Header directive can occur almost anywhere within the server
c3237dec879f82855403ff7e3ba87b298172efd5Mark Andrewsconfiguration. It is valid in the main server config and virtual host
c3237dec879f82855403ff7e3ba87b298172efd5Mark Andrewssections, inside &lt;Directory&gt;, &lt;Location&gt; and &lt;Files&gt;
cb616c6d5c2ece1fac37fa6e0bca2b53d4043098Mark Andrewssections, and within .htaccess files.
cb616c6d5c2ece1fac37fa6e0bca2b53d4043098Mark Andrews<P>
cb616c6d5c2ece1fac37fa6e0bca2b53d4043098Mark AndrewsThe Header directives are processed in the following order:
c0a2210466dec0cc81ebf2ffbe21693b57b9c29cMark Andrews<OL>
c0a2210466dec0cc81ebf2ffbe21693b57b9c29cMark Andrews<LI>main server
c0a2210466dec0cc81ebf2ffbe21693b57b9c29cMark Andrews<LI>virtual host
534057c9f91a3eb6e0541f3526459c716239b337Mark Andrews<LI>&lt;Directory&gt; sections and .htaccess
534057c9f91a3eb6e0541f3526459c716239b337Mark Andrews<LI>&lt;Location&gt;
534057c9f91a3eb6e0541f3526459c716239b337Mark Andrews<LI>&lt;Files&gt;
0f14b041328c062b1fa391887376388dfc8b2fe5Mark Andrews</OL>
0f14b041328c062b1fa391887376388dfc8b2fe5Mark Andrews
0f14b041328c062b1fa391887376388dfc8b2fe5Mark AndrewsOrder is important. These two headers have a different effect if reversed:
0f14b041328c062b1fa391887376388dfc8b2fe5Mark Andrews<PRE>
f7f4730e563a2749629fe7fef4cd9513cd2bfab7Mark AndrewsHeader append Author "John P. Doe"
f7f4730e563a2749629fe7fef4cd9513cd2bfab7Mark AndrewsHeader unset Author
1848d38f441ebf70ab21f6151bc3487a92d25b63Mark Andrews</PRE>
1848d38f441ebf70ab21f6151bc3487a92d25b63Mark Andrews
2d82ed9456e72dc4373bea19d63411afe1c48962Mark AndrewsThis way round, the Author header is not set. If reversed, the Author
2d82ed9456e72dc4373bea19d63411afe1c48962Mark Andrewsheader is set to "John P. Doe".
2d82ed9456e72dc4373bea19d63411afe1c48962Mark Andrews<P>
a5a1cbece45e6ca68aafe3b9b995eac6b0f45dd2Mark Andrews
a5a1cbece45e6ca68aafe3b9b995eac6b0f45dd2Mark AndrewsThe Header directives are processed just before the response is sent
0d6328ce5f6b799f8e7c6cbbb3b965cf29bfb7baMark Andrewsby its handler. These means that some headers that are added just
0d6328ce5f6b799f8e7c6cbbb3b965cf29bfb7baMark Andrewsbefore the response is sent cannot be unset or overridden. This
0d6328ce5f6b799f8e7c6cbbb3b965cf29bfb7baMark Andrewsincludes headers such as "Date" and "Server".
e01ef6f01c7e8f80122cd80a2e011425a0135489Mark Andrews<P>
677f507de7c546c187c1505c48bc7b440545485cMark Andrews
677f507de7c546c187c1505c48bc7b440545485cMark Andrews<!--#include virtual="footer.html" -->
677f507de7c546c187c1505c48bc7b440545485cMark Andrews</BODY>
124cc0660c7eff8021c2422fb47441e9ca08b3f9Tinderbox User</HTML>
e01ef6f01c7e8f80122cd80a2e011425a0135489Mark Andrews