2

What I want to achieve is hitting a URL, say http://myhost/eng/LOGIN/login?BID=12&BFORENAME=C&BSURNAME=C and have those parameters inserted as headers on the request. The parameters are fixed names so I can assume there should always be those 3.

The way I went about doing it was using RewriteRule in httpd.conf to set an environment variable and then RequestHeader to set the header based on the environment variable.

First, can anyone suggest the rules to use, at the moment I'm looking like

RewriteEngine on
RewriteCond %{QUERY_STRING} BID=(.*)&BFORENAME=(.*)&BSURNAME=(.*)
RewriteRule ^(.*) $1? [R,E=VBID:%1,E=VF:%2,E=VS:%3]
RequestHeader set BID "%{VBID}e"
RequestHeader set BF "%{VF}e"
RequestHeader set BS "%{VS}e"

But I keep getting a null header (or no header if I use env=varname).

Can anyone suggest what I am doing wrong and why I can't seem to pass a value from the rewriterule to the headers using environment variables?

1 Answer 1

0

I have answered my own question shortly after I posted by stumbling across a Stack Overflow question that I hadn't seen before. When using environment variables with a RewriteRule that does redirecting then Apache changes the name by prepending REDIRECT_ to the name.

Frustratingly enough, I was only doing a redirect for testing purposes and ultimately I just wanted to capture the parameters as headers so doing a RewriteRule ^/ - avoids the issue altogether.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .