0

We would like to block a certain url coming from a scammy url shortening service that pays per click. The website basically displays our website in an iframe and displays their ads on top.

We've tried using a php redirect to our main page when a specific referrer is detected however it ends up in infinite redirect loop. Also tried a javascript redirect but the domain url doesn't change from theirs to ours.

Ultimately what we want to accomplish is redirect users coming from this short url to our main website and changing the site url from theirs to ours in the url bar.

Is this possible?

Thank you

Bastien
  • 189
  • 1
  • 3
  • 18
  • take a look at http://stackoverflow.com/questions/6768793/get-the-full-url-in-php ..does that help? – ThatMSG Mar 31 '15 at 14:44
  • 1
    Could you show an example of the PHP redirect you setup that ends up creating an infinite redirect loop? – jonnybot Mar 31 '15 at 15:35
  • @ThatMSG No, I am able to get the referrer just fine. I just need to redirect from their http://terribleurlservice.com to my site. – Bastien Mar 31 '15 at 18:28
  • @jonnybot I am using a simple if referrer equals xxx, redirect to homepage.com. Even if I redirect to a page which does not include the code, it redirects but stays on their site. – Bastien Mar 31 '15 at 18:28

1 Answers1

0

If you are redirecting users coming from your home page, to your home page, you will end up with an infinite redirect loop. Either redirect them to a "no hotlinking" page, or add an additional clause to the redirect which excludes visitors to the front page.

djvs
  • 552
  • 2
  • 11
  • Thanks for the reply. I was hoping I could redirect visitors coming this specific url to our homepage, instead of displaying a 404 or no hotlinking page. I am guessing that's not possible. – Bastien Mar 31 '15 at 18:27
  • Of course that's possible. Hard to say exactly how, without knowing if you're using a framework, etc.. – djvs Apr 01 '15 at 00:58
  • I got it to work. Using a javascript snippet detecting if website is being loaded in an iframe. If yes, it redirects to our homepage. Cheers – Bastien Apr 01 '15 at 14:28