如何隐藏链接到访客而不是抓取机器人?

How to do that? I have post on my blog. I want hide links to guest but not for any crawler only in php not javascript. I can't find any information on google so please help with any suggestion.


if ( preg_match("#(google|slurp@inktomi|yahoo! slurp|msnbot)#si", $_SERVER['HTTP_USER_AGENT']) ) {
// do something after recognize
}

Use css

.link-I-want-to-hide{
    display:none;
}

This means the anchor elements will not be physically visible to users, yet exist in the HTML to be parsed by crawlers.

Simply use CSS, just select your HTML elements and apply display: none.

Quick example: https://jsfiddle.net/wz2ryewd/

.hide {
    display: none   
}

Or alternatively, wrap all your guest links in a div, apply the "hide" class on it:

https://jsfiddle.net/wz2ryewd/1/

Just a SEO note to pay some extra attention ...

If your site is perceived to contain hidden text and links that are deceptive in intent, your site may be removed from the Google index, and will not appear in search results pages as Google could applies a penalization.