Page 1 of 1
restricting site access
Posted: Sun Mar 09, 2003 4:25 am
by phpcoder
how can i restrict any site to specific ip. i.e site can only be access from specified IP on local intranet..
plz help
Posted: Sun Mar 09, 2003 5:04 am
by volka
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
Posted: Sun Mar 09, 2003 5:53 am
by lazy_yogi
that may not be the solution though.
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___', '');
?>
then at the very top of each of ur scripts put this line (before anything else at all)
Code: Select all
<?php
if (! isset($_COOKIE['___mysecurity___'])) exit;
?>
the other alternative is sessions
Posted: Sun Mar 09, 2003 6:27 am
by volka
from specified IP on local intranet
I doubt the
local intranet is routed through a NAT-server
