I just launched my first website I fully wrote myself in php/mysql - www.TomPaineToday.com. After testing it on my own computer for a while, I decided I might as well launch it and see what problems I run into.

The first issue I came across was that my link redirect counter loves counting the Google Bot. Now, I am sure many people have had this idea in the past and will tell me why I should not do it, but what problems will I cause if I treat Google Bot "clicks" differently then human clicks by filtering IPs?

After I find out that this will blacklist me from Google or whatever other devastating problems it will cause, is there an open list of IP addresses that I should disregard for future click counting?



Sorry if this is the wrong forum, but since I am doing this in php, thought this was more appropriate than seo/marketing forums.

Member Avatar



Can you post the code? At least.

Yes, it's the wrong forum, it should be in the Internet Marketing section but if you have the php code then there's no problem

Thanks, will move it.

UPDATE: I'm new here... I am not seeing an option to remove a post? :-/

You could always use a robots.txt file to disallow Google bots indexing the click counter links.

Here is the code I have been using. As mentioned above, I was considereing adding different clauses for known bots.

    $user_ip = $_SERVER['REMOTE_ADDR'];
    $time_now = time('%s');
    $tobe_redirect = $_GET['url'];
    $article_id = md5($tobe_redirect);
    $query = "INSERT INTO `stats` ( `article_id` , `user_ip` , `time`) ";
    $query .= "VALUES ('{$article_id}','{$user_ip}', {$time_now})";
    if (mysql_query($query,$connection)) {
    // Success!
    else {
        // Display error message

    $redirect = "Location: " . $_GET['url'];


Thanks for the suggestion. I will look more into that. Other than allowing or disallowing certain pages from being index, I am not familiar with the capabilities of robot.txt files.

Member Avatar



Thanks for posting the code.

I apologize I'm not familiar with SEO. So far from PHP, You created a DB to fetch those info in order to block Google Bot:

$query = "INSERT INTO stats ( article_id , user_ip , time)";

I think what blocblue mention about robots.txt is more appropriate:


I feel blocblue more experience in SEO than I.


The bit of code you reposted is basically the query that adds an entry to the db when a link is accessed. I was considering adding clauses to handle bots differently.

Looks as though that link has my answer. I take it Google would look down on handling them in a different manner then the rest of the world is treated.

Member Avatar



It's good that you post the code now because someone beside me can help you with this.

I'm not familiar with SEO at all and I don't even know how to write code regarding about SEO.

I was considering adding clauses to handle bots differently.

So that will help more

You can use get_browser() function or $_SERVER['HTTP_USER_AGENT'] to read the user agent of the clients and if there is a match with Google bots you will not run the query, something like:


$browser = $_SERVER['HTTP_USER_AGENT'];

    # insert query here
    echo 'bot';


the else statement is optional. Here's the list of Google bots user-agents: https://developers.google.com/webmasters/control-crawl-index/docs/crawlers