Move All 404 To 410

Does your webmaster report has a large 404 page and you want to permanently solve this issue with 410, then your search ends here.

It's a good idea to use HTTP "410 Gone" status over "404 Not Found" because bot treats 404 and 410 differently if you have lots of 404 page then bot try to crawl the page for a longer period of time where 410 is treated as permanently removed so bot does not crawl that again. This post from 2009 by John Mu on Google's Webmaster Central forums says:

"I followed up on the 404 vs 410 thing with the team here. As mentioned by some others here & elsewhere, we have generally been treating them the same in the past.

However, after looking at how webmasters use them in practice we are now treating the 410 HTTP result code as a bit "more permanent" than a 404. So if you're absolutely sure that a page no longer exists and will never exist again, using a 410 would likely be a good thing."

So now the question is how to do this in WordPress?
It can be achieved by going through the following steps

Create a custom page for 410

First, you have to create a custom 'Error 410' page from WordPress admin panel (Dashboard > Pages > Add New) and then give an appropriate title and write the content that you want to display. After writing the content Publish it and note the page ID.

How to implement 410 in WordPress

Add below code in your active theme 404.php file.

Open your active theme 404.php file in notepad or in any other text editor and add the below 4 PHP line at the starting of the file.

<?php

$custom_410_page_ID = 329;//Error 410 page ID
header($_SERVER["SERVER_PROTOCOL"] . " 410 Gone");
header("Refresh: 0; url=" . get_permalink($custom_410_page_ID));
exit();

All done, cheers 🙂 Now when you will see your webmaster report it will show a decrease in an amount of 404 Pages.
Let me know in the comment if you face any difficulty while implementing it or have any suggestion for us then we will love to hear from you.

Raunak Gupta

Raunak Gupta

I'm Raunak Gupta, a seasoned software developer with over 9 years of experience in a wide range of programming languages, frameworks, and tools. I started my journey as a WordPress & CakePHP developer in 2014, diving deep into the world of OOPs, Request handling, and SEO. Along the way, I crafted numerous dazzling WooCommerce stores, tamed payment gateways, optimized for full filament functionality, and achieved ultra-low latency for lightning-fast load times. My expertise extends to BI tools, website builders, DevOps, and team leadership. I like to help upcoming developers, so I share my experience through this blog and by assisting fellow developers on Stack Overflow, where I've earned a stellar reputation with over 10k+ points of recognition.

Articles: 29

4 Comments

  1. WOW, great, and in Firefox it works like a charm, but unfortunately, it is not working in Chrome! 🙁

    I have been searching and seems to be a well know issue, but I cannot solve it.. 🙁

    Any idea? Thanks a lot, regards,

    • Is it? I tried to replicate the issue but I tested in major browsers and it worked like a charm.
      Have you tried in chrome incognito mode?

Leave a Reply

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