I have a multi regional based site and I redirect users according to the IP address.Following is the code to redirect the users according to their country. But this code prevent Googlebot from reaching the pages other than USA. What should be the ideal structure so that googlebot may visit every pages and users are redirected as per their IP address? Thanks in advance.
if ($country == "IN")
{
// do nothing
}
else if ($country == "BD" ")
{
header( 'Location:https://www.exmple.com/directory/bangladesh/index.php');
}
else if ($country == "PK" )
{
header('Location:https://www.exmple.com/directory/pakistan/index.php');
}
else if ($country == "LK" )
{
header('Location:https://www.exmple.com/directory/srilanka/index.php');
}
else if ($country == "US" )
{
header('Location:https://www.exmple.com/directory/usa/index.php');
}
else if ($country == "CA")
{
header('Location:https://www.exmple.com/directory/canada/index.php');
}
else if ($country == "GB")
{
header('Location:https://www.exmple.com/directory/uk/index.php');
}
else if ($country == "NG")
{
header('Location:https://www.exmple.com/directory/nigeria/index.php');
}
else
{
header( 'Location:https://www.exmple.com/directory/global/index.php');
}