October 23, 2015

PHP - Dynamic IP block script.



Please enter the following script in header file of your site which call in all pages for e.g. header.php file,

And also define IP addressed which you want to redirect to another page/link,

Example

<?php $blacklist = array("111.222.333", "444.555.666", "777.888.999");

if(in_array($_SERVER['REMOTE_ADDR'], $blacklist)) {

header("Location: http://sitename.com/404");

exit();
} ?>

Enjoy!

No comments:

Post a Comment

The Future of Technology: Emerging Trends to Watch in 2025

Introduction As we navigate through 2025, the technological landscape continues to evolve at an unprecedented pace. Innovations that once se...