From e3cc634d1362f6fb35becfec66a6edc842cbb78d Mon Sep 17 00:00:00 2001
From: Luca Toscano
An example can help to visualize the whole process. The following configuration uses the
Header
directive of mod_headers
to set
- a specific HTTP header. What value will httpd set in the foo
header for a request to
+ a specific HTTP header. What value will httpd set in the CustomHeaderName
header for a request to
/example/index.html
?
<Directory "/"> - Header set foo one + Header set CustomHeaderName one <FilesMatch ".*"> - Header set foo three + Header set CustomHeaderName three </FilesMatch> </Directory> <Directory "/example"> - Header set foo two + Header set CustomHeaderName two </Directory>
Directory
"/" matches and an initial configuration to set the "foo" header with the value "one" is created.Directory
"/example" matches, and since mod_headers
specifies in its code to override in case of a merge, a new configuration is created to set the "foo" header with the value "two".FilesMatch
".*" matches and another merge opportunity arises, causing the "foo" header
- to be set with the value "three".mod_headers
will be called and it will receive the configuration to set the "foo" header with the value "three". mod_headers
normally uses this configuration to perfom its job, namely setting the foo header. This does not mean that a module can't perform a more complex action like discarding directives because not needed or deprecated, etc..Directory
"/" matches and an initial configuration to set the CustomHeaderName
header with the value one
is created.Directory
"/example" matches, and since mod_headers
specifies in its code to override in case of a merge, a new configuration is created to set the CustomHeaderName
header with the value two
.FilesMatch
".*" matches and another merge opportunity arises, causing the CustomHeaderName
header to be set with the value three
.mod_headers
will be called and it will receive the configuration to set the CustomHeaderName
header with the value three
. mod_headers
normally uses this configuration to perfom its job, namely setting the foo header. This does not mean that a module can't perform a more complex action like discarding directives because not needed or deprecated, etc..This is true for .htaccess too since they have the same priority as Directory
in the merge order. The important concept to understand is that configuration sections like Directory
and FilesMatch
are not comparable to module specific directives like Header
or RewriteRule
because they operate on different levels.
Below is an artificial example to show the order of merging. Assuming they all apply to the request, the directives in -- 2.50.1