mod_headersmod_headers overviewmod_headers module enables HTTP request and response headers modification (i.e. merging, replacement or removal). Early and Late Headers Processingmod_headers can be applied to the request on early or late stage. Default mode is late - Request Headers are set right before running the content generator and sending the response. Late mode must always be used on live server. Early mode was designed for testing puposes. Directives marked with early keyword are set right at the beginning of request processing. Early headers can only be used in server and virtual host context, but are senseless in contexts like <Directory> or <Location>. mod_headers directivesHeader
Header directive allows to replace, merge or remove HTTP response headers. The header is modified just after the content handler and output filters are run, allowing modification of outgoing headers. The optional condition can be either onsuccess or always. It determines, which internal header table should be operated on. onsuccess stands for 2xx status codes and always for all status codes (including 2xx). Especially if you want to unset headers set by certain modules, you should try out, which table is affected. The second argument specifies what action is performed:
The next argument is header name, which may include the final colon, but it is not required. Set, append, add and unset are case-insensitive; echo is case sensitive. The third argument for add, append and set is value. If value contains spaces, it should be put into double quotes. value may be a character string, a string containing format specifiers or a combination of both. The following format specifiers are supported for value:
Header directive may include an additional argument which may specify conditions for action to occur. It may also be early keyword to initiate early processing. If the environment variable specified in the env=... argument exists (or doesn't exist in env=!...), the action specified in Header directive will take place. Otherwise, the directive will have no effect on the request. If not in early mode, Header directives are processed right before the response is sent to the network. Example:
will result in addition of the following header to the response:
RequestHeader
RequestHeader directive allows to replace, merge or remove HTTP request headers. The header is modified just before the content handler is run, allowing incoming headers to be modified. The action it performs is determined by the first argument. This can be one of the following values: The first argument specifies what action is performed:
The next argument is header name, which may include the final colon, but it is not required. Set, append, add and unset are case-insensitive. The value for add, append and set is specified in the third argument, for unset no value is needed. If value contains spaces, it should be put into double quotes. value may be a character string, a string containing format specifiers or a combination of both. Format specifiers are the same as for the Header directive. RequestHeader directive may include an additional argument which may specify conditions for action to occur. It may also be early keyword to initiate early processing. If the environment variable specified in the env=... argument exists (or doesn't exist in env=!...), the action specified in RequestHeader directive will take place. Otherwise, the directive will have no effect on the request. If not in early mode, Header directives are processed right before the response is sent to the network. |