How to change all 404 to 410 error code in Wordpress

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

About The Author

1 thought on “How to change all 404 to 410 error code in WordPress”

  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?

Leave a Comment

Your email address will not be published.

Scroll to Top