Well, the only way to detect geolocation is with a navigator and use it like this:
if(navigator.geolocation) { //Geo in Browser }
So, what would I personally do is create an Ajax request to the server and do the redirection as follows:
if(navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position){ document.location = '/';
on the server side you will do something like this:
<?php /* session/geolocation.php */ //Require system files include '../MasterBootloader.php'; /* * Session is already started in the above inclustion */ if(!isset($_SESSION['geo']['checked']) && is_agax_request()) { $_SESSION['geo'] = array(); if(isset($_GET['postition'])) { $_SESSION['geo']['supported'] = true; $_SESSION['geo']['location'] = json_decode($_REQUEST['geo_position']); } $_SESSION['geo']['checked'] = true; } ?>
now that javascript redirects you, in your index you can check if it exists before the output of your html, then you will know the server side if GEO is supported!
source share