Support » Fixing WordPress » Do I use 404 or 200 then?

  • digitaltoast

    (@digitaltoast)


    The FAQ says:
    ————————————
    “Sending Proper Headers

    By default, WordPress continues to send 404 pages as if they were fine. To make search engines like Google spider these pages correctly, you can add this line to the top of your theme’s 404.php file.

    <?php header(“HTTP/1.1 404 Not Found”); ?>
    ————————————

    But my 404 template already says:

    ————————————
    <?php
    header(“HTTP/1.1 200 OK”);
    header(“Status: 200 OK”);
    ?>
    ————————————

    Quite a difference there! Which is right?

Viewing 5 replies - 1 through 5 (of 5 total)
  • maerk

    (@maerk)

    If the post is gone, a 404 is best since it means that the resource wasn’t found.

    If you have a 200 it sends the message that the resource is fine, i.e. that the “post not found” message is the post, which I’m sure you don’t want Google to think 😉

    prjg

    (@iiiiiiiv)

    Actually, if it’s “gone” then it’s code 410 🙂

    If something is not found, doesn’t exist, spelled wrong or is simply not there it’s 404.

    Sending out any other HTTP response is outright wrong. 200 especially is wrong.

    The Horse’s Mouth

    maerk

    (@maerk)

    Actually, if it’s “gone” then it’s code 410 🙂

    No I know, but how would you set WP so that it sent out 410 for deleted posts?! I mean, I think once you’ve deleted a post, WP completely forgets about it, so unless you maintain a list of slugs that you’ve deleted, it would be pretty much impossible.

    Plus, the HTTP spec says that 410 is an optional code 😉 404 is just fine.

    prjg

    (@iiiiiiiv)

    No I know, but how would you set WP so that it sent out 410 for deleted posts?!

    In a .htaccess in your blog directory.

    Redirect gone http://url_of_deleted_post

    In theory, anyway. How you’d do this for what is essentially a dynamically generated URL is beyond me.

    maerk

    (@maerk)

    I meant how would you get WP to use the 410 header automatically when a post is deleted 🙂

    Actually, that would be an awesome plugin. I recently deleted a load of posts, and it would have been much better if, when they were requested, I could return a 410 deleted message instead of just a “not found”. Much more user-friendly.

    Might make a feature request for that, actually.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Do I use 404 or 200 then?’ is closed to new replies.