php - only allow certain ips to access my "family site"? -
for days have been struggeling making ips accessing family site since want family enable access site. ill need guys. how far have gotten , if ip not in database redirect www.google.com .
the code:
$ip =$_server['remote_addr']; $result = mysql_query('select * `ips` `ip`="' . $ip . '"'); if(mysql_affected_rows($link) < 0){ header('location:http://google.com'); }
edit: got idea of can use wont change computer mac address code need change of table , names inside. how go , when user try access site check if mac adress of computer in database else redirect google.com.
kind regards fredrik
if use apache webserver can change directory node content in httpd.conf
configuration file allow your_ip , deny all. more suitable place create such restrictions.
note default apache access <directory /> allow all. means apache serve file mapped url. change block such as
<directory /> order deny,allow deny allow ip </directory>
and override directories want accessible.
for redirect part can add httpd.conf
redirect google on 403 forbidden errors. don't forget restart webserver after made changes.
errordocument 403 http://www.google.com
Comments
Post a Comment