fri3ndly Posted February 29, 2008 Share Posted February 29, 2008 Hello I have this code: <body> <div id="wrapper"> <div id="header-bar"><?php echo date("j M Y | H:i:s"); ?></div> <div id="header"> <div id="logo"> <h1>Website Title<h1> When the search engines index this site, the date of the index will also be indexed and will display as the text for the website description. Is there a way either with PHP or CSS to stop search engines reading what is in 'header-bar'? Link to comment https://forums.phpfreaks.com/topic/93704-hiding-text-from-search-engine/ Share on other sites More sharing options...
tinker Posted February 29, 2008 Share Posted February 29, 2008 Have a look here at the robots section (at bottom) Link to comment https://forums.phpfreaks.com/topic/93704-hiding-text-from-search-engine/#findComment-480109 Share on other sites More sharing options...
fri3ndly Posted February 29, 2008 Author Share Posted February 29, 2008 Hi thanks for the reply Yes I know about robots, but I just need to make it not index one line of my page. If I made date.php a seperate page in a seperate folder, included it in the index and told robots not to index that folder would that work? Link to comment https://forums.phpfreaks.com/topic/93704-hiding-text-from-search-engine/#findComment-480112 Share on other sites More sharing options...
tinker Posted February 29, 2008 Share Posted February 29, 2008 a robot is like an automatic browser, so it downloads the page to client side (probably another process searches it later), so what you have to do is recognise that it's a bot and just not serve it up to it. Have a look at $_SERVER['HTTP_USER_AGENT'], then regex it against some rules for detecting bot's... or some people check against ip ranges... Link to comment https://forums.phpfreaks.com/topic/93704-hiding-text-from-search-engine/#findComment-480123 Share on other sites More sharing options...
fri3ndly Posted February 29, 2008 Author Share Posted February 29, 2008 Thanks So... <? if (($_SERVER["HTTP_USER_AGENT"] == "googlebot")) { echo ""; } else { echo date("j M Y | H:i:s"); } ?> Would that be correct? Link to comment https://forums.phpfreaks.com/topic/93704-hiding-text-from-search-engine/#findComment-480145 Share on other sites More sharing options...
tinker Posted February 29, 2008 Share Posted February 29, 2008 If you were doing that i'd use: if (strcmp($_SERVER["HTTP_USER_AGENT"], "googlebot")==0) But i'd suggest using some form of regex. e.g: if (preg_match("/google(bot)?/i", $_SERVER["HTTP_USER_AGENT"]) { echo ""; } else { echo date("j M Y | H:i:s"); } Link to comment https://forums.phpfreaks.com/topic/93704-hiding-text-from-search-engine/#findComment-480151 Share on other sites More sharing options...
tinker Posted February 29, 2008 Share Posted February 29, 2008 Here's a link which has a few bot's agent strings... and some code for splitting and checking ranges of ip's... Link to comment https://forums.phpfreaks.com/topic/93704-hiding-text-from-search-engine/#findComment-480163 Share on other sites More sharing options...
fri3ndly Posted February 29, 2008 Author Share Posted February 29, 2008 Thanks a lot tinker! Link to comment https://forums.phpfreaks.com/topic/93704-hiding-text-from-search-engine/#findComment-480166 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.