httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Csaba Gabor <>
Subject Example of modifying and output of Environment to Header
Date Tue, 11 Dec 2001 06:42:45 GMT
Environment variables seem to be fleeting creatures at times.  Here now, gone at log time.
maybe I want to alter it by means of a regular expression even though apache only allows fixed
values for the most part.

Here's an example of how I remember an environment variable's value to a Header field that
handles the above ideas:

# This section copies a variable, and then place it into the header for non empty variables
# The next line saves the environment variable SCRIPT_URI to %1
RewriteCond %{ENV:SCRIPT_URI} (.*)
# The next line saves it to TestVar and continues.
# If I don't want to do anything with empty values I could use (^?.*$) or something similar
RewriteRule .* - [C=1,E=TestVar:%1]
# This again saves the same environment variable to %1
RewriteCond %{ENV:TestVar} (.*)
# The next part again works with the pieces collected from the RewriteCond line.
RewriteRule .* - [E=NewVar:The\ Value\ is\:\ %1]
# Finally, set the header MyHeaderTest to the newly constructed value
# provided the original variable was not empty
Header set MyHeaderTest %{NewVar}e env=TestVar

Do You Yahoo!?
Check out Yahoo! Shopping and Yahoo! Auctions for all of
your unique holiday gifts! Buy at
or bid at

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message