Forum Moderators: phranque

Message Too Old, No Replies

Redirect passing Form Vars (POST Context)

looking to move a cart

         

bsterz

4:08 pm on Apr 8, 2004 (gmt 0)

10+ Year Member



Greetings,

This one has me kinda flummoxed..

I have about 14 billion different pages pointing to a cart page. I need to move the cart page. I would like to put in a redirect to say:

"Take every POST and GET variable passed to this page and send it to the new page".

So:

Visitor posts to:
example.com/cart/index.php
This gets redirected to:
someotherhost/cart/index.php
with all post and get vars intact.

htaccess, perl, or php solutions would be cool, but I would love to do it with a nice tidy htaccess file.

Thanks for any help,

Bill

jatar_k

11:26 pm on Apr 8, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I was sitting around with a friend talking about this and we thought of rewrite

essentially it would rewrite the request and should still post everything to the new file

but

then we figured just symlink it

ln -s /path/to/newfile.php /path/to/oldfile.php

bsterz

1:02 am on Apr 9, 2004 (gmt 0)

10+ Year Member



Thanks for tryin', but the new cart is off-site.

Thanks again,

Bill

jdMorgan

8:11 am on Apr 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



mod_rewrite can easily redirect your GETs and POSTs. GETs are obviously not a problem. POST data is sent in the message-body of the request, and is untouched by mod_rewrite; The client sees the redirect, and simply re-posts to the new URL.

Jim

bsterz

9:30 pm on Apr 9, 2004 (gmt 0)

10+ Year Member



I thought that was the case but when I create a form and redirect, the $_POST var is empty.

Here is my form code:
<form name="form1" method="post" action="https://2.2.2.2/redirect/">
<input name="name" type="text" id="name" value="ttttttttttttttt">
</form>

Here is my .htacess code (in root of 2.2.2.2/redirect):
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)$ [1.1.1.1...] [R]

Here is my showvar.php code:
<?=$_POST["name"]?>

Any pointers would be appreciated.

Bill

Birdman

9:48 pm on Apr 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can you do a PHP redirect?

If the data isn't sensitive(ie product info) you could put a header() redirect and change the POST vars to GET vars.

foreach($_POST as $key => $val) $formfields .= "&".$key."=".urlencode($val);
header("Location: newurl.php?r=0".$formfields);
exit;

Note:
The?r=0 part of the redirect is just a dummy var so all the rest can use the & delimiter.

Sorry if this is of no help.

bsterz

10:02 pm on Apr 9, 2004 (gmt 0)

10+ Year Member



I think that may be the way I have to go. I had held out hope for a slick redirection thingy - but no soap.

Thanks for the help - I'll give this a try now.

Bill