Search code examples
phpseogoogle-searchgoogle-ranking

how can I redirect users coming from a Google search, but not Google crawler for the same page?


I wondered if there is a way to redirect users that come from a Google search to my homepage when the ranked page isn't the homepage, without interfering the good ranking for that page.

What I need is a php condition to understand if the webpage is reached from a user that comes from a Google search and not from the Google crawler. I need Google crawler to continue indexing that page, and at the same time, users to be redirected to the homepage. This is a pseudocode snipped of what I mean:

if ($_SERVER['HTTP_REFERER'] == 'only users from a Google search') 
    header('location','index.php');

Solution

  • Don't use any of these techniques, you should treat Google like any user, don't add any filters or conditions in your code.

    We call this technique cloaking, its one of the most dangerous spam techniques and Google will penalize you.