alex alex - 6 months ago 23
PHP Question

Is it possible to redirect post data?

I have a website where all requests are redirected silently (via

.htaccess
) to
index.php
and then PHP is used to show the correct page (by parsing the
REQUEST_URI
).

I was wondering if it's possible to submit POST data to a fake address too?

I've currently got my form like so...

<form action="/send-mail" method="post">


And my
.htaccess
rule is...

# redirect mail posting to index
RewriteRule send-mail index.php?send-mail [NC,L]


My
index.php
checks
isset($_GET['send-mail'])
which works fine.

This however seems to drop off all the POST data that should be sent to it.

Is there a way to keep the post data? I don't want to use GET because it can't send as much information, though it might not be an issue with a simple inquiry form.

Here is my
.htaccess
for redirecting to
index.php


# serve files and dirs if they exist please, otherwise send to index
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php

Answer

Try this:

# redirect mail posting to index
     RewriteRule send-mail index.php?send-mail [NC,P]

"P" acts like "L" in that it stops processing rules but it also tells the module that the request should be passed off to the proxy module intact (meaning POST data is preserved).