Use apache to strip off a URL param and add it as a custom HTTP header on a redirect
Solution 1:
This turned out to be possible by combining RewriteRule
with Proxy
<VirtualHost *:80>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*)memberUuid=(.*)$
RewriteRule ^/(.*)$ http://127.0.0.1:9000/$1 [E=memberUuid:%2,P]
ProxyPreserveHost On
ProxyPass /excluded !
ProxyPass / http://127.0.0.1:9000/
ProxyPassReverse / http://127.0.0.1:9000/
Header add iv-user "%{memberUuid}e"
RequestHeader set iv-user "%{memberUuid}e"
</VirtualHost>
Solution 2:
It's not possible as described. The stateless nature of HTTP means that you cannot associate a current response with a future request unless you use a mechanism such as cookies.
Solution 3:
To answer to your edited question about mod_headers
, you are probably misunderstanding. The module lets you add additional request headers on server end. You can not force clients to send specific headers freely unless you have a communication rule over HTTP protocol b/w clients and server.
You can probably want to go with Cookie. you can use Set-Cookie
header. I am not 100% sure if you can use cookie over sites running on different port, but I thought it could work as long as domain name is the same. About cookie, even wikipedia explains very well.
http://en.wikipedia.org/wiki/HTTP_cookie
EDIT: I personally use php a lot so here is a very simple example to set Cookie and redirect in PHP:
// set cookie value
setcookie('uuid', $_GET['memberUuid'], time() + 3600);
// redirect
header('Location: http://localhost:9000/accounts');
exit;
and you can retrieve the cookie value by $_COOKIE['uuid']
on localhost:9000
EDIT 2:
If you only configure on apache, mod_headers won't be able to do this job since it doesn't handle GET variables as far as I know. Instead, mod_rewrite may work.
RewriteEngine On
RewriteRule ^/accounts\?memberUuid=(.*) http://localhost:9000/accounts [R,CO=uuid:$1:localhost:1440:/]
I didn't test this but I know mod_rewrite is capable of retrieving values from your URL, setting Cookies, and redirection.