In this short tutorial we will learn how to blocking bad referrer site using php script. This idea coming into my head after I’m sick looking at bad referrer site which take opportunity to earn money using my articles. Example: the baddest shortest URL, this site shorten URL but it’s reported contain spyware and malware on ads from that page.

This will lead our site in problem because people may think we’re spreading spyware/malware. Even if we claim we don’t created that link I believe 99% people wouldn’t trust us. The best thing to stop this madness is blocking that referrer site to stop referring people into our page.

This php script will using php referrer function to detected referrer site. In this short code sample we may will be needed more manual working. I believe someone can created better one or maybe a nice plugins? you’re ALLOWED to use this script code.

Before I’m going to write the code I just want to tell everyone I already try to blocking bad referrer via .htacces file but it’s not working, I believe there something missing on there… So here is the sample code:



The problem is when we’re trying to block another bad site we have to edit this code manually. I hope someone would try to make plugins using this code. At least this code works when I try to blocking some referrer from it’s SUCCESS!

For wordpress user where to put this code? Open your admin panel and edit your header.php file, put this code in the top of your header code. This sample script will checking, if referrer coming from badsite it will stop loading pages and giving warning message. When it coming directly of safe site like google, yahoo, bing, etc it will work as usual.

That’s my share for today, happy weekend everyone, enjoy your day 🙂


Similar Posts:

Related Search Terms:

    Digg StumbleUpon Reddit Twitter RSS

If you're new here, you may want to subscribe to my RSS feed. You may copy or publish this article to your blog or other site as long you give credit link back to this site article. Thanks for visiting my blog!