skip to Main Content

Im trying to replace all 404 error code with 410 gone request which is good for SEO
I have tried the following snippet from TheDevBlog Post

if ( is_404() ) {
            define( 'DONOTCACHEPAGE', true );       // WP Super Cache and W3 Total Cache recognise this
            status_header( 410 ); }

This is not working, i have checked the syntax & they are correct, why is it not working? what am i missing?

2

Answers


  1. You also need to add 410.php to your theme directory.

    You can create 410.php and copy the page template to see the result.

    Login or Signup to reply.
  2. Here what you are looking to achieve.

    <?php
    if ( is_404() ) {
    header( "HTTP/1.1 410 Gone" ); } ?>
    

    This will replace all 404 status to 410 .

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search