I have a 3rd party who POST
's to a specific page on my website. They post a file and my site does some wizardry with the contents of that file.
The request URL would be for example https://example.com/product-configrator
Sometimes they use a string in their REFERER
url like:
https://referrer.com/embed/section.htm?bikes=1
If the referrer passes traffic to me with the argument bikes=1
(contained within the HTTP_REFERER
rather than the QUERY_STRING
) I'd like to serve up a different page.
Here's an example of an access.log entry where the 3rd party is posting to my site:
90.xxx.xxx.xxx- - [21/Oct/2019:15:03:51 +0000] "POST /product-configurator HTTP/1.1" 200 23505 "https://referrer.com/embed/products.htm?bikes=1" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36"
So, they're POST
ing to my /product-configrator
page. I want to redirect this to /bikes-configrator
retaining the POST
data (using a 307)
I've tested a redirect using some htaccess syntax testing tools but can't get the correct syntax.
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^(.*)\.referrer\.(.*)./*bikes* [NC]
RewriteRule ^(.*)$ https://www.example.com/bikes-configurator [R=307,L]
How can I do this? I know this question has been done to death but I can't see an example that matches my question. I've also asked this question recently on Stack Overflow but the responses I received didn't help me construct a valid entry in my .htaccess file. Any help gratefully appreciated.
bikes=1
in theHTTP_REFERER
string/bikes-configurator
then routed in your app? (This presumably does not map directly to a physical file?)if (isset($_POST["bike"])) { do stuff ...}