Requires shellexec()
index.php
<?php
$url = "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
$escaped_url = "https:".htmlspecialchars( $url, ENT_QUOTES, 'UTF-8' );
$command='grep -Fxn "'.$escaped_url.'" '.__DIR__ . '/gone_urls.txt';
$out=shell_exec($command);
if($out){
header("HTTP/1.1 200 OK");
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Sorry, this page is gone forever and ever</title>
<meta name="robots" content="noindex">
</head>
<body>
<h1>Sorry, this page is gone forever and ever</h1>
</body>
</html>
<?php
die();
}
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define( 'WP_USE_THEMES', true );
/** Loads the WordPress Environment and Template */
require __DIR__ . '/wp-blog-header.php';
create a text file containing all URLs and name it gone_urls.txt
gone_urls.txt
https://www.agrarinfo.ch/wp-content/uploads/2016/09/1609bauernstimmekleinteil15.pdfhttps://www.agrarinfo.ch/wp-content/uploads/2016/01/hafl-shareburger.pdfhttps://www.agrarinfo.ch/wp-content/uploads/2017/12/einsichten_nr5_p10.pdfhttps://www.agrarinfo.ch/wp-content/uploads/2016/09/a3-flyer-zu-ttip-resolution.pdfhttps://www.agrarinfo.ch/wp-content/uploads/2017/11/3tinagoethe_www.pdf