Modifying the name of a POST parameter in apache

apache-2.2

I'd like to change the name of a POST parameter from "SURNAME" to "LASTNAME" using apache.

The reason being that we have legacy client doing a post to a legacy server. Neither can be modified, which is why I'd like to do the translation in Apache. I've used mod_rewrite to translate some querystring values, however posts are out of reach of mod_rewrite.

So, does anybody know how to manipulate the name of a post parameter?

Best Answer

Yeah, that's a bad situation. mod_rewrite doesn't help you with POST data, mod_filter and mod_ext_filter only work on output, and mod_reflector returns the altered request immediately.

So, unless you feel like writing an apache module (mod_filter_request.so, or whatever), one way or another, you're going to have to mangle the client request before it gets to the server and, worse yet, it needs to be invisible at the transport level (which reminds me, you didn't mention if this was over SSL or not -- if so, your mangler is now going to be responsible for all SSL, since you have to "look inside" to change the variable).

So, roughly speaking (the specifics will depend a lot on how you are currently set up):

Step 1: set up a public-facing very simple website that simply passes all requests to a single script

(EDIT: What I had won't work because it will lose the POST variable; just map everything to this one script as the handler...)

Step 2: write pass.pl (or whatever). It should a) take the request b) store all variables c) generate a new request to the legacy server d) receive the response e) send that response back to the original client

(There are so many set-up assumptions there that I'm not even going to try a code example.)

Bluntly, it's probably not worth it, and you might be better off changing the variable name in whatever system the legacy server writes to (does it have hooks you can access)?