From: Eric Covener The optional condition argument determines which internal
table of responses headers this directive will operate against:
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: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.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
- X-Foo: bar header to each HTTP response. As described above,
- 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:always is provided relative to each
+ action below.
Please read the difference between 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.
Carefully read the difference between always
+ and onsuccess for each action listed below as the
+ behavior can be unintuitive and is a frequent source of confusion.
+ Where the guidance suggest repeating the conditions, it is safe to try
+ each experimentally and use the one you find effective to match the
+ pre-existing header.
set,
- append or merge should be used instead.
+ append or merge should be used instead.
+ Specify a condition of always if you want the header to
+ be included in non-2xx response (such as redirects or errors)
appendIf the header was added by this module, you must match the condition
+ parameter that was originally used. Otherwise, you must determine by trial
+ and error whether always should be specified because you can't
+ reliably know which internal table the existing value is present in.
echoSpecify a condition of always if you want the header to
+ be included in non-2xx response (such as redirects or errors).
editedit*edit form will match and replace exactly once
in a header value, whereas the edit* form will replace
every instance of the search pattern if it appears more
- than once.
+ than once.
+ Because you cannot reliably know which internal header table might have a match,
+ you should repeat your edit/edit* directive with both always and
+ onsuccess.
mergeIf the header was added by this module, you must match the condition
+ parameter that was originally used. Otherwise, you must determine by trial
+ and error whether always should be specified because you can't
+ reliably know which internal table the existing value is present in.
setIf the header was added by this module, you must match the condition
+ parameter that was originally used. Otherwise, you must determine by trial
+ and error whether always should be specified because you can't
+ reliably know which internal table the existing value is present in.
setifemptyIf the header was added by this module, you must match the condition
+ parameter that was originally used. Otherwise, you must determine by trial
+ and error whether always should be specified because you can't
+ reliably know which internal table the existing value is present in.
unsetBecause you cannot reliably know which internal header table might have a match,
+ you should repeat your this directive with both always and
+ onsuccess.
noteIf the header was added by this module, you must match the condition
+ parameter that was originally used. Otherwise, you must determine by trial
+ and error whether always should be specified because you can't
+ reliably know which internal table the existing value is present in.