How to block traffic from specific sites

How to block recieving traffic from specific sites
Traffic is very necessary thing for any blog. Getting a real and organic traffic is really a hard thing for newbies. Their are many ways to gain a traffic to your blog. In these ways many are legal and also many are illegal. So the topic itself describe it's mean that how to block receiving traffic from specific websites.






Why we block traffic from specific websites

Many friends now thinking that why should we block traffic receiving from specific websites. So i have an answer of this question. Receiving traffic from low quality sites or the sites which are banned or blocked by google is dangerous for your site. This can make your google adsense account banned. And also decrease your search engine visibility.

From which sites should i stop traffic?

So now the question is that from which site you should stop receiving traffic. So for this i created a simple list of some types of sites where you should have to stop receiving traffic. 
  • Pornographic / nudeness Content
  • Copied content
  • Pirated Material
  • Hacking Content
  • Based On Black Hat SEO
  • And all other illegal  things

How to block traffic from specific sites

Block traffic through javascript

Bloggers can not add php code to their blog so that's why for them they use javascript and paste the below javascript in their templates.

Step 1

The first step is to copy the below javascript and paste it in your site.
<script type=’text/javascript’>
var block = ['url One', 'url Two'];
for (var b = block.length; b–;) {
if (document.referrer.match(block[b]))
window.location = “http://google.com/”;
}
</script>
 You should replace the url one and url two with the sites url from where you want to block traffic. You can also add more than two urls. And then save your template.

Block traffic through PHP

Copy the below code and add it to your site home page. You should replace the url one and URL TWO with your sites url from where you want to block traffic.
$block = ['url One', 'url Two'];
foreach ($block as $value) {
if ($_SERVER['HTTP_REFERRER'] == $value)
header(‘Location: http://google.com/’);
}

From Editor's Desk

Hope this tutorial will help you. If have any problem or any question you feel free to share it with me. I try to solve your problem as early as possible.
How to block traffic from specific sites How to block traffic from specific sites Reviewed by Maher Afrasiab on 5:47:00 am Rating: 5

No comments:

Powered by Blogger.