Support » Fixing WordPress » htaccess code to delete 404 error to 410 gone

  • Hi,
    I would like to use the htaccess file to tell Google that several pages have been permanently deleted using error 410. I have this code and would like to know if it will work:

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^.*$ /errorpage.php [L]

    and I created a php file with these lines:

    <?php header($_SERVER[‘SERVER_PROTOCOL’].’ 410 Gone’);

    Will this tell Google to no longer give me a 404 error but rather a 410 error?

    Thanks a lot,
    Martin

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi Martin,

    Your code should work without any issue. Alternatively, rather than adding RewriteRule ^.*$ /errorpage.php [L] under .htaccess, you can simply add RewriteRule .* - [G,L].

    .* means that it will do this for any URL on your site
    – means to leave the URL alone and not change it
    G means “Gone” — send the 410 status
    L means “Last” — so that no other rewrite rules are executed

    Thank you for your reply.
    Regards,
    Martin

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘htaccess code to delete 404 error to 410 gone’ is closed to new replies.