PHP redirection to same domain and solve redirection loop issue

Hi,

When I try to redirect to the same domain based on some of the conditions like geolocation, I am getting the issue of the redirection loop.

Any idea how to fix it?

You’d need to set a flag on the first redirection to tell your code that the redirection has already been done.

Well more to the point, code the thing so that it doesnt redirect at all if you’re already at the right place. Less annoying to the user, cause it sounds like you’re redirecting everyone.

We’re not going to be able to give you more advice than that without seeing the code you’re using.

I have 2 domains configured inside 1 website. My website supports multis-store.

For example domain.fr and domain.de.

if ($Geocountry==“Germany”) { header(“Location:domain.de”); exit; }
if ($Geocountry==“France”) { header(“Location:domain.fr”); exit; }

Since both domains in the same website, I am getting redirection in the loop issue.

$IAmLookingAt = array_pop(explode(".",$_SERVER['HTTP_HOST']));
if ($Geocountry==“Germany” && $IAmLookingAt != "de") { header(“Location:domain.de”); exit; }
if ($Geocountry==“France” && $IAmLookingAt != "fr") { header(“Location:domain.fr”); exit; }

Thanks. I will test and update.

Since domains .de and .fr in the same website mean visitors from .de or .fr will go the same website with different domains