2017-01-06 1 views
0

Comment bloquer (redirect) une page si la page est dans un fichier txt:Comment bloquer certaines pages si dans le fichier txt

Je cet extrait - les bonnes nouvelles est l'URL dans block.txt sera bloqué (site blanc), mais je veux qu'il rediriger vers /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; 
} 
?> 

Répondre

0

Essayez ce code ..

//require_once dirname(__FILE__) . '/file-not-found.php'; 
header('Location: http://www.example.com/file-not-found.php'); 

Remerciez