EllisLab text mark
Advanced Search
Fetch request from google mobile robot does not set is_mobile() to TRUE
Posted: 08 March 2012 12:07 PM
Joined: 2011-07-12
5 posts

I’m using this tool test how Google indexes the mobile version of my site.

However, regardless of which mobile version I choose (Mobile: cHTML, XHTML/WML, or Smartphone) it always returns the desktop version of the site.

I know settings can be tweaked in the user-agents config file, but I’m looking for guidance as to how.  This is important because it’s against google’s policies to server a different version of the page to google than your regular users.  And if they are both using a cellphone, this is something I’m currently doing.

Is there a string I can add to the user agent arrays to detect google mobile bot?  And more importantly, where should I include it? Since the order of the array also matters.

Thanks a ton for your help.

Posted: 13 April 2012 07:10 PM   [ # 1 ]   [ Rating: 0 ]
Joined: 2011-07-12
5 posts

Incase anyone else ever faces this problem, I’ll post the solution I’ve been meaning to post for a while.

in system/libraries/User_agent.php

private function _set_robot()
if (is_array($this->robots) AND count($this->robots) > 0)
foreach ($this->robots as $key => $val)
if (preg_match("|".preg_quote($key)."|i"$this->agent))
->is_robot TRUE;
$this->robot $val;
return FALSE;

This will set the mobile correctly even when a robot is visiting.

Posted: 14 April 2012 05:51 PM   [ # 2 ]   [ Rating: 0 ]
Joined: 2007-11-28
2435 posts

I added this as a pull request. Nice addition, thanks.