apache2 – Include %{TIME_YEAR} Variable in HTTP Response Header

Apache2http-headerslinux

I'm trying to do something like the following:

<If "%{IPV6} == 'off'">
  Header always set Attention "you are using still using IPV4 in %{TIME_YEAR}, please blahblah etc"
</If>

(please withhold commentary regarding the viability of communicating with humans through HTTP headers)

without the %{TIME_YEAR} it works fine but with it it gives an error Unrecognized header format %,

removing the % just results in the literal string {TIME_YEAR} being returned in the header

I've tried using expr=%{TIME_YEAR} or %{env:TIME_YEAR} but they error out as well

I've tried adding PassEnv TIME_YEAR prior but it gives an error AH01506: PassEnv variable TIME_YEAR was undefined

TIME_YEAR should be a valid variable according to this: https://httpd.apache.org/docs/2.4/expr.html

I noticed that some variable on that page are tagged as "(not available during <If>)" but there's no such designation on the time variables

I am using Apache 2.4.41 which (as far as I can tell) should be sufficient to have all of this functionality.

Best Answer

This should work:

Header always set Attention "expr=you are using still using IPV4 in %{TIME_YEAR}, please blahblah etc"