I know this isn't a very Magento question, but I'm hoping someone in the community has dealt with this.

We have a multi-store setup with more than 10 stores (different languages and domains), which share many products between them.

The problem:

If we want to do a product promotion on say - Instagram, and include a product URL in the description, it would only be one store (obviously, its dumb to direct a Spanish customer to a Danish site), so:

How to create a "universal" URL which will automatically redirect the customer to the correct store (based on location and language).

Note: Our sites do have hreflang with alternate hrefs set up.

1 Answer 1


I would suggest using the Open Weather API. With that, you can detect the city and country. Here is an example.

After, you could do a Strpos function on PHP to gather the variables, and do "if" conditions. After, you could do something like that:

$variable_with_all_countries = ['AR', 'BR', 'DE', 'EN'];
$strpos = strpos($country_name, $variable_with_all_countries);
if ($strpos === 'DE') { header('Location: http://www.yourcorrectsite.com/');  }

That's my suggestion. Let me know if you got it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.