Skip to content

Instantly share code, notes, and snippets.

@anerdev
Created March 14, 2014 16:10
Show Gist options
  • Save anerdev/9550845 to your computer and use it in GitHub Desktop.
Save anerdev/9550845 to your computer and use it in GitHub Desktop.
Php redirect based from ip
<?php
$ip = explode(".", $_SERVER['REMOTE_ADDR']); // Save in the array "ip" the octects of the ip
if ($ip[0] == 192) { // read the first octect, and for example, if you are from the internal lan, where the pc's ip start with "192" redirect to "index_lan.html"
header("location: index_lan.html");
}
else { // if the ip doesn't start with 192, redirect to "index_wan.html"
header("location: index_wan.html");
};
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment