How do you hide links from search engine bots in ajax?

michaelr1988

Regular Member
Apr 25, 2011
489
317
How do you hide links from search engine bots in ajax? I have 3 links in my footer that I want to be visible to visitors but hidden from search engine bots. Anyone can point me in the right direction of a easy to follow guide, been struggling with this for a couple of hours now.

Cheers.
 
By ajax I assume you mean JavaScript. You can get the user agent string from a visitor, but the problem is that not all crawlers/spiders use JavaScript. So the best option here is, if you can, to use something like the following PHP script:

Code:
<?php
function isUserBot() {
    $bots = array(
        'googlebot',
        'bing'
        // Whatever the other bots' user agents are
    );

    foreach ($bots as $bot) {  
        if (strstr(strtolower($_SERVER['HTTP_USER_AGENT']), $bot)) return true;
    }

  return false;
}
?>

And then just
Code:
<?php if (!isUserBot()) : ?>
<a href="#">Link 1</a> | <a href="#">Link 2</a> | ...
<?php endif; ?>
 
Back
Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features and essential functions on BlackHatWorld and other forums. These functions are unrelated to ads, such as internal links and images. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock