Is there a way (which I am sure there is) to block IP addresses using code. I want the code to be in PHP so that I can put it in my child themes function.php to use for block some IP addresses. Thanks


Place in your template's index.php the following piece of code:

$deny = array("", "");

if (in_array ($_SERVER['REMOTE_ADDR'], $deny)) 
    header("Location: http://example.com");

And just change the addresses of $deny for the IP address or addresses you want to block.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.