function check_broken_link() {
global $wpdb;
$table_name = $wpdb->prefix . 'bad_urls';
$current_url = $_SERVER['REQUEST_URI'];
$result = $wpdb->get_row("SELECT * FROM $table_name WHERE url = '$current_url'");
if ($result) {
// Send "410 Gone" header
header($_SERVER["SERVER_PROTOCOL"] . " 410 Gone");
exit();
}
}
add_action('template_redirect', 'check_broken_link');
0 Comments
Post a Comment