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'? Quote Link to comment 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) Quote Link to comment 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? Quote Link to comment 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... Quote Link to comment 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? Quote Link to comment 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"); } Quote Link to comment 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... Quote Link to comment Share on other sites More sharing options...
fri3ndly Posted February 29, 2008 Author Share Posted February 29, 2008 Thanks a lot tinker! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.