WordPress.org

Ready to get started?Download WordPress

Forums

Do I use 404 or 200 then? (6 posts)

  1. digitaltoast
    Member
    Posted 8 years ago #

    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?

  2. maerk
    Member
    Posted 8 years ago #

    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 ;)

  3. IIIIIIIV
    Member
    Posted 8 years ago #

    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

  4. maerk
    Member
    Posted 8 years ago #

    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.

  5. IIIIIIIV
    Member
    Posted 8 years ago #

    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.

  6. maerk
    Member
    Posted 8 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags