0

I have a 3rd party who passes traffic to my website.

Sometimes they use a string in their url like:

https://referrer.com/embed/section.htm?bikes=1

If the referrer passes traffic to me with the argument bikes=1 I'd like to serve up a different page.

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

EDIT

I've tried editting .htaccess with the following but it breaks access to the entire site (with a 500 error)

RewriteEngine On
RewriteCond %{HTTP_REFERER} ^(.*)\.referrer\.(.*)\(*bikes*) [NC]
RewriteRule ^(.*)$ https://www.my-site.com/bikes [L,R]

Another Edit!

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 /products 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 POSTing to my /products page. I want to redirect this to /bikes retaining the POST data (using 307 as suggested by @DeanTaylor

I've tested this out using some mod_rewrite testing tools but can't get the correct syntax.

6
  • You can achieve it with server-side code (like php) as well as using htaccess. In php you can use $_GET to access query string and in htaccess you can write rewrite-condition. Come back with your initial effort. Commented Oct 19, 2019 at 15:40
  • Hmm, after reading a bit more into it, I think what I need might not be achievable. The 3rd party is POSTing data to me. If I initiate a conditional redirect, I think I'll lose the POST - is this correct? Commented Oct 19, 2019 at 15:52
  • To me it is unclear if you are talking about the URL actually requested from you or about the referrer URL. Those two are something quite different. Commented Oct 19, 2019 at 16:37
  • The referrer posts to my site. I want to redirect to a different page depending on the contents of the referrer URL Commented Oct 19, 2019 at 19:36
  • @Huskie69 you can use "307 Temporary Redirect" via [R=307,L] to cause the browser to re-submit the same POST data to the new URL. Commented Oct 21, 2019 at 12:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.