Jump to content

Recommended Posts

I am trying to filter search bots from redirecting to mobile version of website.

I am planning to create crawlers array and prevent them to redirect to mobile version of site.

 

function cDetect($USER_AGENT) {
$crawlers = array(
array('Google', 'Google'),
array('msnbot', 'MSN'),
array('Rambler', 'Rambler'),
array('Yahoo', 'Yahoo')
);

foreach ($crawlers as $c) {
if (stristr($USER_AGENT, $c[0])) {
return($c[1]);
}
}
return false;
}

//// Now let us work on it

$findcrawler = cDetect($_SERVER['HTTP_USER_AGENT']);
if ($findcrawler) {

}else{
header ("Location: http://m.domain.com/");
}

 

Now when I change user agent of browser with each and every bot user agent and browse the site, code works fine and shows me web version of site and I am happy with that.

 

Now, is it require that search bots must contains "search engine name" in their user agent ?

In other words, can google bot crawl my site using another user agent ?

 

Is this a valid way to detect user agents of search bots ? Please guide me. Thanx in advance. :)

Link to comment
https://forums.phpfreaks.com/topic/208762-quick-help-google-useragent/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.