for some days i have been struggeling with making only certain ips accessing my family site since i only want my family to be enable to access the site. ill need some help by your guys. This is how far i have gotten and if ip is not in database it will redirect to http://www.google.com .
The code:
$ip =$_SERVER['REMOTE_ADDR'];
$result = mysql_query('SELECT * FROM `ips` WHERE `ip`="' . $ip . '"');
if(mysql_affected_rows($link) < 0){
header('location:http://google.com');
}
EDIT: Got an idea of what i can use that wont change the computer mac address so the code will need change of the table and the names inside. How will i go about that , so when the user try to access my site it does a check if the mac adress of the computer is in database else redirect to google.com.
Kind regards Fredrik
If you use Apache as your webserver you can change the directory node content in the
httpd.confconfiguration file to Allow from YOUR_IP and Deny from all. This is usually a more suitable place to create such restrictions.Note that the default Apache access for <Directory /> is Allow from All. This means that Apache will serve any file mapped from an URL. Change this with a block such as
and then override this for directories you want accessible.
For the redirect part you can add this to your
httpd.confto redirect to google on 403 Forbidden errors. Don’t forget to restart the webserver after you made the changes.ErrorDocument 403 http://www.google.com