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');