404-to-410
| |

How to change all 404 to 410 error code in WordPress

If you want to change all 404 error of your WordPress website into 410 error statues then just add this code before the get_header(); in you 404.php template

<?php
// Set 410 - GONE status for all 404 pages
header($_SERVER["SERVER_PROTOCOL"] . " 410 Gone");
get_header();
?>

Hope it helps.

Reference: stackoverflow.com

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

One Comment

  1. What is the difference between 404 and 410? The 404 indicates, that the resource is not present at the given location, and it has probably never been (or the server has no idea whether it has been). The 410, on the other hand, indicates that resource is not present anymore, but it used to be there in the past.
    But, Which is better?