Turns out this config needs to be inside the <VirtualHost>
, which is a pain since I was trying to load from conf.d
Not necessarily.
(Knowing that these directives were in the main server config, outside of the existing vHost, is an important point missing from your question.)
"The problem" is that the mod_rewrite directives in the server config are not inherited by the <VirtualHost>
container by default. The Header
directive (part of mod_headers) in the server config is processed, but since the mod_rewrite directives have not run and not set the LONGCACHE
environment variable, the header is not set.
If you were on Apache 2.4 then you can use SetEnvIfExpr
(mod_setenvif) to set the environment variable based on the presence of the query string, and avoid using mod_rewrite.
On Apache 2.2 you would need to enable mod_rewrite inheritance in the <VirtualHost>
container:
RewriteEngine On
RewriteOptions Inherit
Note, however, that the directives from the server config are inherited after the directives in the virtualhost context (NB: directives in <Directory>
containers do not apply as they run later - in a directory context). This means that directives in the vHost could potentially prevent the server directives from being executed. (On Apache 2.4+ you have more control over how the directives are inherited.)
OR, include these "shared" directives in a separate config file and include
the config file in each vhost as required.