Apache: scope for environmental variables

apache-2.2environment-variablesrewrite

While there's documentation available on Apache environmental variables, I can not find answer to one important question. Imagine I use rewrite rules to set environmental variable

RewriteRule ... ... [E=something:1]

What is the scope of "something" – global Apache server (this means "something" will be available for other request transactions), this request (means that "something" is only valid for THIS http request (and its related processing – but what's about internal redirects and other internal stuff – are they considered as THIS request, or another one?), and may be set differently within another (concurrent) request?

Best Answer

The scope is this request and can be set differently in another concurrent request. The relevant part of the docs is this:

Conditional Per-Request Settings

For additional flexibility, the directives provided by mod_setenvif allow environment variables to be set on a per-request basis, conditional on characteristics of particular requests. For example, a variable could be set only when a specific browser (User-Agent) is making a request, or only when a specific Referer [sic] header is found. Even more flexibility is available through the mod_rewrite's RewriteRule which uses the [E=...] option to set environment variables.

source