Welcome Guest, Not a member yet? Register   Sign In
Redirection by value of $ _SERVER [ 'REMOTE_ADDR']
#1

[eluser]laegnur[/eluser]
Another question of mine.

How to do, that for the value of $_SERVER['REMOTE_ADDR'], if the IP is local, show content, and if the IP is external, redirect to another site?
#2

[eluser]bretticus[/eluser]
You could probably use a regular expression of even a str* function, however, there are ways to do this to check if the remote ip is in the same range as your internal network.

See this page
#3

[eluser]laegnur[/eluser]
Hi!

Thanks for you answer. With this article, and using his function, I was able to do so.

Code:
if(isSet($_SERVER['REMOTE_ADDR']))
{
  if(ip_in_range($_SERVER['REMOTE_ADDR'],'192.168.*.*'))
  {
    echo 'Intranet content';
  }
  else
  {
    header('Location: /internet_content/index.php');
  }
}




Theme © iAndrew 2016 - Forum software by © MyBB