From: Luca Toscano This directive can replace, merge or remove HTTP response
@@ -228,16 +228,12 @@ available in 2.4.10 and later
modified. The optional condition argument determines which internal
- table of responses headers this directive will operate against. Despite the
- name, the default value of When your action is a function of an existing header, you may need to specify
- a condition of Separately from the condition parameter described above, you
- can limit an action based on HTTP status codes for e.g. proxied or CGI
+ This difference between To circumvent this limitation, there are some known configuration
+ patterns that can help, like the following: Separately from the condition parameter described above, you
+ can limit an action based on HTTP status codes for e.g. proxied or CGI
requests. See the example that uses %{REQUEST_STATUS} in the section above. The action it performs is determined by the first
argument (second argument if a condition is specified).
This can be one of the following values: Please read the difference between Override: FileInfo Status: Extension
-Module: mod_headers Compatibility: SetIfEmpty available in 2.4.7 and later, expr=value
+ Compatibility: SetIfEmpty available in 2.4.7 and later, expr=value
available in 2.4.10 and later onsuccess does not limit
- an action to responses with a 2xx status code. Headers set under
- this condition are still used when, for example, a request is successfully
- proxied or generated by CGI, even when they have generated a failing status code.always, depending on which internal table the
- original header was set in. The table that corresponds to always is
- used for locally generated error responses as well as successful responses.
+ table of responses headers this directive will operate against:
+ onsuccess (default, can be omitted) or always.
+ The difference between the two lists is that the headers contained in the
+ latter are added to the response even on error, and persisted across
+ internal redirects (for example, ErrorDocument handlers).
+
Note also that repeating this directive with both conditions makes sense in
some scenarios because always is not a superset of
onsuccess with respect to existing headers:always is used in the ultimate response.mod_proxy_fcgi,
+ in which case the CGI scripts' headers are in the table corresponding to
always and not in the default table.onsuccess condition.onsuccess and always is
+ a feature that resulted as a consequence of how httpd internally stores
+ headers for a HTTP response, since it does not offer any "normalized" single
+ list of headers. The main problem that can arise if the following concept
+ is not kept in mind while writing the configuration is that some HTTP responses
+ might end up with the same header duplicated (confusing users or sometimes even
+ HTTP clients). For example, suppose that you have a simple PHP proxy setup with
+ mod_proxy_fcgi and your backend PHP scripts adds the
+ X-Foo: bar header to each HTTP response. As described above,
+ mod_proxy_fcgi uses the always table to store
+ headers, so a configuration like the following ends up in the wrong result, namely
+ having the header duplicated with both values:# X-Foo's value is set in the 'onsuccess' headers table
+Header set X-Foo: baz
+
+
+ # 'onsuccess' can be omitted since it is the default
+Header onsuccess unset X-Foo
+Header always set X-Foo "baz"
+
+
+ Warning
+ always
+ and onsuccess headers list described above
+ before start reading the actions list, since that important
+ concept still applies. Each action, in fact, works as described
+ but only on the target headers list.
addadd a value is specified as the next argument.
If value
contains spaces, it should be surrounded by double quotes.
- value may be a character string, a string containing
- mod_headers specific format specifiers (and character
+ value may be a character string, a string containing
+ mod_headers specific format specifiers (and character
literals), or an ap_expr expression prefixed
with expr=
The following format specifiers are supported in value:
| Format | Description |
|---|---|
| Override: | FileInfo |
| Status: | Extension |
| Module: | mod_headers |
| Compatibility: | SetIfEmpty available in 2.4.7 and later, expr=value + |
| Compatibility: | SetIfEmpty available in 2.4.7 and later, expr=value available in 2.4.10 and later |
This directive can replace, merge, change or remove HTTP request