Forum Moderators: phranque

Message Too Old, No Replies

Redirect POST requests

"Location:" only works with GET?

         

longjohn

1:01 pm on Jul 15, 2005 (gmt 0)

10+ Year Member



Hi everybody,
a user is filling a form (name=john surname=smith)and sending me (www.mysite.com) the POST request.
I'd like to transparently redirect him to another server.
If the request were a GET one (www.mysite.com/apps/example?name=john&surname=smith) I'd just redirect him by sending him the header "Location: www.newsite.com/apps1/example1?name=john&surname=smith".

What can I do to achieve the same with POST requests?
Any idea (maybe javascript)?
Thanks a lot.

jdMorgan

2:24 pm on Jul 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Redirecting POSTs is a security problem and possibly a violation of the user's trust. As a result, it doesn't work across most platforms. On those where it does work, the client is required to ask the user whether the redirect should be allowed.

See RFC2616 - HTTP/1.1 [w3.org] descriptions of the 301 and 302 redirect server responses and their associated warnings.

The best approach is to switch domains before presenting the form page that POSTs information -- In other words, put the form on the same domain as you want to POST to.

Jim