geo redirect which work with https

james250

Newbie
Joined
Aug 25, 2010
Messages
48
Reaction score
1
Code:
<head>
<script src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script>
<script type="text/javascript">

    switch(geoplugin_countryCode()){
        case "US" :
            document.location.href = "https://yahoo.com/";
            break;
        case "GB" :
            document.location.href = "https://yahoo.com/"
            break;
        case "CA" :
            document.location.href = "https://yahoo.com/"
            break;
         default :
            document.location.href = "https://google.com/"
            break;
    }
</script>
</head>
this geo redirect code worked properly, but if i use https in my domain it wont work. can anyone help me to run geo redirect this or any which work in https.

thanks
 
Strange cause the above code works for me using https. What kind of error are you seeing?
 
Last edited:
Try to replace this:
<script src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script>

with this:
<script src="https://www.geoplugin.net/javascript.gp" type="text/javascript"></script>
 
Or better yet:
<script src="//www.geoplugin.net/javascript.gp" type="text/javascript"></script>

Try to replace this:
<script src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script>

with this:
<script src="https://www.geoplugin.net/javascript.gp" type="text/javascript"></script>
 
Strange cause the above code works for me using https. What kind of error are you seeing?
nothing error show, see this : https://profilefbviews.com/test.php .

can you show your link
 
Try to replace this:
<script src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script>

with this:
<script src="https://www.geoplugin.net/javascript.gp" type="text/javascript"></script>

i already try this, not working
 
Try this in straight PHP:
Code:
<?php
$location_data_json= file_get_contents('http://www.geoplugin.net/json.gp?ip='.$_SERVER['REMOTE_ADDR']);
$location_data_array = json_decode($location_data_json);
switch ($location_data_array->geoplugin_countryCode) {
    case "US":
        header("Location: https://google.com/");
        break;
    case "GB":
        header("Location: https://google.co.uk/");
        break;
    case "CA":
        header("Location: https://google.ca/");
        break;
    default:
        header("Location: https://google.com/");
}
?>

i try this too, not working
 
Try this in straight PHP:
Code:
<?php
$location_data_json= file_get_contents('http://www.geoplugin.net/json.gp?ip='.$_SERVER['REMOTE_ADDR']);
$location_data_array = json_decode($location_data_json);
switch ($location_data_array->geoplugin_countryCode) {
    case "US":
        header("Location: https://google.com/");
        break;
    case "GB":
        header("Location: https://google.co.uk/");
        break;
    case "CA":
        header("Location: https://google.ca/");
        break;
    default:
        header("Location: https://google.com/");
}
?>


thanks mate, finally worked :)
 
Back
Top