in my site i have a redirect via header(“location”) which only will be executed when the user logged in not exists, redirecting to the login form. I have a google+ button on this site and google always follows the redirect. I cannot get it why?
When i remove this redirect everything is fine. I tried with this code:
if (!$user->user_exists && !getIsCrawler($userAgent)) {
header("Location: login.php"); }
To detect the crawler i use this function:
$userAgent = $_SERVER['HTTP_USER_AGENT'];
function getIsCrawler($userAgent) {
$crawlers = 'Google|msnbot|Rambler|Yahoo|AbachoBOT|accoona|' . 'AcioRobot|ASPSeek|CocoCrawler|Dumbot|FAST-WebCrawler|'
.'GeonaBot|Gigabot|Lycos|MSRBOT|Scooter|AltaVista|IDBot|eStyle|Scrubby'; $isCrawler =
(preg_match("/$crawlers/", $userAgent) > 0); return $isCrawler; }
What am i doing wrong here? I hope that someone of you have a solution for this.
Unfortunately, I don’t think it is possible to get around this problem. Google is known to be using different user agents (with obscure names) in order to check for web pages that show different content to search engines and regular users, or the so called cloaking/doorway pages.