Skip to content

Instantly share code, notes, and snippets.

@twfahey1
Created April 24, 2020 16:59
Show Gist options
  • Save twfahey1/4d9414b3ef3291f97e726cc39b9329e2 to your computer and use it in GitHub Desktop.
Save twfahey1/4d9414b3ef3291f97e726cc39b9329e2 to your computer and use it in GitHub Desktop.
Block IP addresses in PHP
<?php
$deny = array("111.111.111", "222.222.222", "333.333.333");
if (in_array ($_SERVER['REMOTE_ADDR'], $deny)) {
header("location: https://example.com/");
exit();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment