Viewed   58 times

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



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).

Wednesday, December 7, 2022

$1 corresponds to your first set of parenthesis in the first part of your rewrite rule. $2 to the second set of parenthesis and so on.

Daves%20Gourmet contains a space character which is not accounted for in your 2nd pattern i.e. things between 2nd set of parenthesis. Again you are not taking care of _ in the url.

I would try this

RewriteRule ^product/([a-zA-Z]+)/([sa-zA-Z0-9]+)/([0-9]+)/([A-Z0-9]+)/([a-zA-Z_]+) /product?&cat=$1&q=$2&page=$3&prod=$4&prodName=$5

Assuming your page parameter is always an integer and your 4th parameter contains only upper case letters.

Saturday, August 6, 2022

You can use this rule as your first rule in root .htaccess:

RewriteEngine On

RewriteRule ^(.*?)="{{store(.*)$ /$1$2 [L,R=301]
Wednesday, September 21, 2022

Long story short: no, it's not possibile using PHP.

One way I can think of doing this is to output the new form output as hidden fields along with javascript to auto-submit the form ...

It's the only way to do it.

The question is a possible duplicate of PHP Redirect with POST data.

As a suicide solution, you may consider to use HTTP 307 - Temporary Redirect.
From the HTTP/1.1 documentation linked above:

If the 307 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.

My bold simply emphasizes that the redirect without the user confirmation actually depends on the browser's implementation of the protocol.

The redirect can be implemented in the PHP script which receives the POST request as follows&ast;:

header('HTTP/1.1 307 Temporary Redirect');
header('Location: <your page in an external site>');

Basic usage Example:

page1.html - the page which contains the form

    <form method="POST" action="page2.php">
      <input name="variable1" />
      <input name="variable2" />
      <input type="submit" />

page2.php - the page which processes your POST data before redirect


if (isset($_POST['variable1']) && isset($_POST['variable2'])) {

  //do your processing stuff

  header('HTTP/1.1 307 Temporary Redirect');
  header('Location: page3.php');

} else
    echo 'variable1 and variable2 are not set';

page3.php the page to which the POST data has to be redirected (i.e. the external site)


if (isset($_POST['variable1']) && isset($_POST['variable2'])) {

    foreach ($_POST as $key=>$val)
        echo $key . ' = ' . $val . '<br>';

} else
    echo 'variable1 and variable2 are not set';

&ast; don't try this at home!

Monday, September 26, 2022

You are going to have to put a proxy in the middle and monitor that proxy. You can use that allows you to pass in proxy details to WebDriver and then you can pull out a HAR file which shows all the network traffic.

You can also use HARPy to then get the info you want

Example of BrowserMob Proxy and Selenium

            from browsermobproxy import Server

            server = Server("path/to/browsermob-proxy")
            proxy = server.create_proxy()

            from selenium import webdriver
            profile  = webdriver.FirefoxProfile()
            driver = webdriver.Firefox(firefox_profile=profile)

            proxy.har # returns a HAR JSON blob

Saturday, August 6, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :