SetEnvIfExpr with response header

Solution 1:

If may be evaluated too early in Apache's processing to use attributes of the response. The documentation isn't clear and I can't find that elsewhere right now.

But the Header directive is processed late, so it can use the response. You just need to add the expr condition to it:

Header add X-test-foobar "foobarnew" "expr=resp('X-foo') == 'bar'"