how can i restrict any site to specific ip. i.e site can only be access from specified IP on local intranet..
plz help
restricting site access
Moderator: General Moderators
if you're using apache as webserver you might set an "allow from" directive in httpd.conf or .htaccess. http://httpd.apache.org/docs/mod/mod_access.html#allow
If you want to do it with php (or have to), $_SERVER['REMOTE_ADDR'] contains the IP of the visitor.
http://www.php.net/manual/en/reserved.variables.php
If you want to do it with php (or have to), $_SERVER['REMOTE_ADDR'] contains the IP of the visitor.
http://www.php.net/manual/en/reserved.variables.php
that may not be the solution though.
My flatmates and I are on the same LAN and $_SERVER['REMOTE_ADDR'] gives the same ip for each of us. I think it gives the ip of the interface router instead of our individual ip's.
_________________________________________________________
sounds like u might need to use a cookie
Specific IP often means a specific computer.
So when on that computer just put this in a script and run the script once (more doesn't make any diff, but wont hurt it)then at the very top of each of ur scripts put this line (before anything else at all)the other alternative is sessions
how can i restrict any site to specific ip. i.e site can only be access from specified IP on local intranet..
My flatmates and I are on the same LAN and $_SERVER['REMOTE_ADDR'] gives the same ip for each of us. I think it gives the ip of the interface router instead of our individual ip's.
_________________________________________________________
sounds like u might need to use a cookie
Specific IP often means a specific computer.
So when on that computer just put this in a script and run the script once (more doesn't make any diff, but wont hurt it)
Code: Select all
<?php
setcookie('___mysecurity___', '');
?>Code: Select all
<?php
if (! isset($_COOKIE['___mysecurity___'])) exit;
?>