error: Content is protected !!


Mark's Locksmith

You can use a PHP script to restrict access to a URL directory based on IP address. Here's an example script that you can use:

$allowed_ips = array('', ''); // add the IP addresses you want to allow access here


if (!in_array($ip, $allowed_ips)) {
  header('HTTP/1.0 403 Forbidden');
  die('Access denied');

This script defines an array of allowed IP addresses and compares the user's IP address ($_SERVER['REMOTE_ADDR']) with the list of allowed IPs. If the user's IP address is not in the allowed list, the script sends a 403 Forbidden status code and a message indicating that access is denied.

To use this script, save it as a PHP file (e.g. access.php) and upload it to the directory you want to restrict access to. Then, when someone tries to access that directory, the script will run and either allow or deny access based on the IP address.

Note that this script only provides basic IP-based access control and can be bypassed if the user knows how to spoof their IP address. For more robust access control, you should consider using a web server-level solution like ACLs or firewall rules.

Click to listen highlighted text!