I have a requirement, where I need to set the RequestHeader
with a value retrieved from the querystring of the URI.
Approach adopted is to write the RewriteCond
and ReWriteRule
where
the condition is to extract value from %{QUERYSTRING}
variable and set this into another Environment variable and later refer this and add it to request header.
But this doesn't seem to be working for me. I am using Apache 2.2 on RHEL.
My httpd configuration placed in one of .conf file is as below.
RewriteCond %{QUERY_STRING} ^(\w+)=(\w+)$
RewriteRule . - [E=RU:%1]
Header set "X-Header" "%{RU}e" env=RU
NOTE: I also tried to set the request header by hard coding the value and I also have proxy module enabled.
RequestHeader set X-User-ID "test"
Header append X-test %{RU}e
RequestHeader set X-UserID %{RU}e early
Using "early" option also didn't help.
RewriteEngine On
just before the RewriteCond. I struck an issue today where I needed to specifyRewriteEngine On
again after another existing RewriteEngine On; RewriteCond ...; RewriteRule ... configuration.RewriteEngine On
just before theRewriteCond
didn't help. And by enabling Rewrite Log , in the logs able to see that value is set to Environment variable. But RequestHeader and Header is not able to read this value.