• What seems to be the trouble?

    And so, I’m guessing that wordpress does not really give out a true 404 error, when content has been moved or deleted.

    I’m a writer, and so I have those moments when I decide that something I’ve written is terrible, so I might change it completely, with a new title and everything, or I might delete it, and pray that no one should ever come looking for it again.

    …Sometimes people do come looking for it again. This is where WordPress’ 404 handling comes in handy, kinda.
    I read this page: https://codex.www.ads-software.com/Creating_an_Error_404_Page

    and I took this advice:

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

    After doing that, there is still soemthing fishy about the 404 behavior. The two points I mentioned above, they are still in effect.

    I tried to address the first point by installing the plugin called Log 404. This makes a seperate log, and these 404 results do not show up in my server log.

    I wondered if I was getting a “true 404” header response, so I checked it via the Check Server Headers Tool – HTTP Status Codes Checker. It says I do have a real 404, thanks to the php header line.

    But the Google removal came back denied. Is this because there’s content on the page that shows, even on a deleted posts’ address? I deleted everything on 404.php except for that php header stuff. Will that help? Still no results in the log.

Viewing 1 replies (of 1 total)
  • What version of WP are you using? I’m using 2.0.1 and it does send the proper headers for 404 errors, 2.0 did it as well, I’m guessing the codex is out of date. If you are using an older version, you might just need to place the proper header on the 404 page, as the codex indicated.

    As for adding the errors to your server log, put this code on your 404 page or have it executed only when a 404 happens, ie: is_404():

    <?php
    $Error='[client '.$_SERVER['REMOTE_ADDR'] .'] File does not exist: /path/to/www-root'.$_SERVER['REQUEST_URI'];
    if ($_SERVER['HTTP_REFERER']) $Error .=', referer: '.$_SERVER['HTTP_REFERER'];
    error_log($Error, 0);
    ?>

    That creates a server log entry identical to any other ones on my server, you may need to tweak it for yours.

    Good luck,
    Michael.

    PS: The log404 plugin seemed to cause issues for me, the above code is based on the code from the plugin.

Viewing 1 replies (of 1 total)
  • The topic ‘WordPress and the real 404 Error’ is closed to new replies.