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 *

2 Comments

  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?

    1. 410 Status Code Usage: 404 Resources should be cleaned and also changed their status code to the 410. Every HTTP Status Code has a special meaning for the crawlers. 410 Status Code means “Gone” instead of missing. In any Log Analyse, a Holistic SEO can see that Googlebot tries to catch the deleted assets. This also consumes crawl quota. Telling Googlebot that those assets are not necessary anymore will stop Googlebot from crawling those assets. Saved crawl quota will be used for the existing assets. This change can be analyzed during the Log Analysis.