redirect using PHP - POST lost

April 28, 2010 at 10:26:45
Specs: Win XP, P4/1GB
I am attempting to use PHP code to do redirection (rewriting) of URLs on my site, using the header("Location: ... function. This is because some of my URL text searches and changes are rather complex and are very difficult to do in .htaccess. Having good string-handling functions makes it much, much, easier. Anyway, the redirection works, but the problem is that POST data from forms is lost in the process. This is a well-known problem due to the way that header() is implemented.

My question is, what is the best way to deal with this problem? I see many solutions suggested, but they all seem to involve modifying the action script (data receiver) to, e.g., use GET instead of POST. The thing is, I want to plug arbitrary forum, blog, and ecommerce software into my site, and not have to track down all the action scripts and modify them. Some sensitive data shouldn't be exposed in a GET string, anyway. In other words, the Holy Grail is to rebuild the POST data so that the unmodified form data handlers in various apps don't even realize there's been a redirection. Is there a good, clean, application-independent way to do this? I have been studying the WordPress code, but it's so poorly documented that I'm just not sure how they handle it. Can anyone give a lead on where to look for this?


See More: redirect using PHP - POST lost

Report •

August 19, 2010 at 20:52:05
Use sessions.
store things in session variables, that should much more secure than POST data.

Report •

August 20, 2010 at 09:34:22
Thanks, but wouldn't that involve modifying the targeted applications (i.e., to receive data in a different way than their scripts do now)? That's what I'm trying to avoid.

Report •

Related Solutions

Ask Question