You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Csaba Gabor <cs...@yahoo.com> on 2001/12/11 07:42:45 UTC

Example of modifying and output of Environment to Header

Environment variables seem to be fleeting creatures at times.  Here now, gone at log time.  Or
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
above
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 http://shopping.yahoo.com
or bid at http://auctions.yahoo.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org