Dodgy referral links - can they be stopped?

Discussions of secure PHP coding. Security in software is important, so don't be afraid to ask. And when answering: be anal. Nitpick. No security vulnerability is too small.

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Dodgy referral links - can they be stopped?

Post by simonmlewis »

We run a site that has tens of thousands of links from "Google hated" web sites.
I know how to 301 a page to another page, but how do we identify the URL it's come from - and say "if the referral URL is 'x', then take the link to 'b'".

Can this be done in PHP or htaccess?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Dodgy referral links - can they be stopped?

Post by Celauran »

Sort of. You can use the HTTP_REFERER header to try and detect it, but it can be spoofed and so shouldn't be considered reliable.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Dodgy referral links - can they be stopped?

Post by simonmlewis »

Ta - I have tried that and it does work. But as you say, it can be spoofed.

I've since been told that even tho it's being pointed elsewhere on the site, it's still COMING to the site - so needs to be dealt with directly thru google.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Post Reply