A 404 error occurs when a user tries to access a non-existing page of your blog on WordPress – because maybe coming from a site that has linked to evil, or because you have deleted / moved / renamed a page, and so on.
A tip quite widespread is to optimize the error page 404 (the various recommendations would add to insert the error related articles). I, however, I would not stop here, but I would try to implement an error log, to be able to analyze and correct, if possible!
In fact, if an external site is linking incorrectly your own page (perhaps by inserting a typo in the URL), a backlink is “wasted.” If you can understand what the page that the webmaster wanted link, why not implement a 301 redirect that leads visitors (and search engines) to the correct page, rather than to the error page? 😉
Or you may have moved your blog (as I did, from Techlog to Technoburger), and have done something wrong to make the redirect!
Especially in the latter case, it is very important to know when to be able to promptly correct the error 404. If you think you’ve made a few mistakes, you can make WordPress notify you via email showing:
- the url misprint
- the referrer page of the link (if you were to be an external link)
You can implement this rudimentary logging system simply by editing 404.php file of your theme, and adding these lines of PHP code at the end of the file:
//404 mail report!
$url = $_SERVER['REQUEST_URI'];
$referer = $_SERVER['HTTP_REFERER'];
if ($referer == "") $referer = "No referer";
$mail_body = "URL = $url\nREFERER = $referer";
(I made sure that mails have all the same object, so that gmail, if you intend to use it, to comfortably organize in threads – or to facilitate the creation of a filter).
Obviously, I do not recommend to implement this system on a blog in which you expect to receive many 404 errors, not to excessively overload the server. In this case, a log file would be better – or you can take advantage of the Google Webmaster Tools!