php - How to block some Pages if in .txt file
337
How to block (redirect) a Page if the Page is in a .txt file:
I have this snippet - the good news is the url in block.txt will be blocked (white Site) but i want it to redirect to /file-not-found.php
<?php
list($blockExist, $blockData) = array(false, null);
if (is_string($blockData = @file_get_contents('/block.txt'))) {
$blockData = preg_replace('/\s+/', '', $blockData);
}
if (isset($_SERVER['REQUEST_URI'])) {
$httpLink = explode('?', $_SERVER['REQUEST_URI']);
$httpLink = $httpLink[0] == '/' ? null : $httpLink[0];
}
if ($blockData != null && $httpLink != null && stripos("{$blockData}http://", "{$httpLink}http://") !== false) {
$blockExist = true;
}
if ($blockExist) {
require_once dirname(__FILE__) . '/file-not-found.php';
exit;
}
?>
Answer
Solution:
Try this code..
Thank