samoht Posted December 18, 2009 Share Posted December 18, 2009 Hello all, I have a SEO problem because I have setup a quick form on my index.php for the user to set a session variable. Once set the user is introduced to the content of the site - based on his session var he may or may not see a few items. I need to be able to send the robots passed the form with the session var set to "USA" How can I do that?? Thanks, Link to comment https://forums.phpfreaks.com/topic/185609-robot-accomidation/ Share on other sites More sharing options...
zq29 Posted December 18, 2009 Share Posted December 18, 2009 You could check the User Agent string ($_SERVER['HTTP_USER_AGENT']) and if it matches a search engine robot, set the session variable. Link to comment https://forums.phpfreaks.com/topic/185609-robot-accomidation/#findComment-980176 Share on other sites More sharing options...
samoht Posted December 19, 2009 Author Share Posted December 19, 2009 So could I: session_start(); if(strstr(strtolower($_SERVER['HTTP_USER_AGENT']), "googlebot")) { $_SESSION['country'] = "USA"; header ('Location: http://www.mywebpage.com/index.php'); } // ... rest of the code ?? I assume that will work but what if I want a list of robot names? Can I create an array and just stick it in my condition? Also regarding the robot names: - does "Slurp" work for yahoo, or do I need to specify the name like Slurp.so/1.0 Slurp/2.0j Slurp/2.0 Slurp/3.0 ?? Thanks, Link to comment https://forums.phpfreaks.com/topic/185609-robot-accomidation/#findComment-980564 Share on other sites More sharing options...
samoht Posted December 19, 2009 Author Share Posted December 19, 2009 So I tried: session_start(); $bots = array ('Googlebot','MSN','Slurp/3.0','Slurp.so/1.0','Slurp/2.0j','Slurp/2.0','Scooter','Scrubby'); if(strstr(strtolower($_SERVER['HTTP_USER_AGENT']), $bots)) { $_SESSION['country'] = "USA"; header ('Location: http://www.mywebsite.com/index.php'); } but that doesn't seem to work. where this: session_start(); if(strstr(strtolower($_SERVER['HTTP_USER_AGENT']), "googlebot")) { $_SESSION['country'] = "USA"; header ('Location: http://www.mywebsite.com/index.php'); } works for the Googlebot/2.1 Any idea why?? Link to comment https://forums.phpfreaks.com/topic/185609-robot-accomidation/#findComment-980576 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.