Wordpress change all 404 to 410 error code Wordpress change all 404 to 410 error code wordpress wordpress

Wordpress change all 404 to 410 error code


you don't need to create a page.just add this code before the get_header(); in you 404.php template

header($_SERVER["SERVER_PROTOCOL"] . " 410 Gone");

Hope this helps!


You can either use this plugin which will come handy for you, or you can follow the given steps to achieve this without using any plugin.

  1. Create a Page form WordPress Admin panel as Error 410 (or with any name of your choice)
  2. Write your content in that page which you want to show to the user.
  3. After publishing the page you can get the page ID from the URL
  4. Add the given code in your active theme 404.php file.

Code for 404.php

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

Now when any on visit your old URL or mistype any URL it will be redirected to Error 410 page with 410 status code to .

Reference: Move All 404 To 410

Hope this helps!


On the chrome browser the above code was not working like in other browsers.I modified the above code to the code below. Now the 404 errors directs to the 410 page. I guess this is how it supposed to work. Do notify me if there are an mistake in the code i edited?

$custom_410_page_ID = 2242;//Error 410 page IDheader($_SERVER["SERVER_PROTOCOL"] . " 410 Gone");header("Location: " . get_permalink($custom_410_page_ID));exit();