Skip to content

Instantly share code, notes, and snippets.

@Draknek
Created October 5, 2021 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Draknek/0b7e1f14fc37cce41f2cab81b8e8a850 to your computer and use it in GitHub Desktop.
Save Draknek/0b7e1f14fc37cce41f2cab81b8e8a850 to your computer and use it in GitHub Desktop.
Redirect to region-specific Switch storepage
<?php
$ip = $_SERVER['REMOTE_ADDR'];
try {
$ip_data = json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip));
if ($ip_data->geoplugin_continentCode == 'EU') // Europe
{
header('Location: https://www.nintendo.co.uk/Games/Nintendo-Switch-download-software/Bonfire-Peaks-2041254.html');
exit;
}
else if ($ip_data->geoplugin_continentCode == 'OC') // Oceania
{
header('Location: https://ec.nintendo.com/AU/en/titles/70010000044714');
exit;
}
else if ($ip_data->geoplugin_countryCode == 'JP') // Japan
{
header('Location: https://store-jp.nintendo.com/list/software/70010000044721.html');
exit;
}
}
catch (Exception $e)
{
// oh well
}
// Fall back to Americas
header('Location: https://www.nintendo.com/games/detail/bonfire-peaks-switch/');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment