Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.