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

closed as off-topic by fuxia Oct 2 '15 at 20:17

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.


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.

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