Ticket #1128 (closed defect: duplicate)
Improved 404 reporting
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | |
| Component: | Front-end | Version: | 1.0-rc-3 (trunk) |
| Severity: | minor | Keywords: | 404 permalinks improvements |
| Cc: |
Description
In trying to debug the problem with my bbPress implementation on my SunOS host, it became very important to know who generated the 404 errors I encountered when browsing to my bbPress home directory. Specifically, I needed to know who was reporting the 404 error (i.e. who was calling '404.php' in the selected template), and what uri was considered bad. To do this, I enhanced the 404.php module and added a single line to bb_repermalink. The simple changes greatly assisted in determining the problem.
I would submit them as an enhancement for future releases.
First, I created a GLOBALS variable as follows, in bb_repermalink:
if ( $check != $uri && $check != str_replace(urlencode($_original_id), $_original_id, $uri) ) {
if ( $issue_404 && rtrim( $check, " \t\n\r\0\x0B/" ) !== rtrim( $uri, " \t\n\r\0\x0B/" ) ) {
status_header( 404 );
$GLOBALS['bad404url'] = 'From functions.bb-core.bb_repermalink $uri: >' . $uri . '<';
bb_load_template( '404.php' );
} else {
wp_redirect( $permalink );
}
exit;
}
And the 404.php code was modified slightly (I'm using the default 'Kakumei' template:
<h2 id="http404"><?php _e('Page not found!'); ?></h2>
<p>
<?php _e('I\'m sorry, but there is nothing at the URL:'); ?><br/>
<b><?php
_e($GLOBALS['bad404url']);?>
<br/></b>
<!-- //_e('['); _e(strlen($GLOBALS['bad404url'])); _e(' bytes]'); ?><br/></b> -->
</p>
The basic intent here is to not just tell the user that there is a '404 Error', but to give him (and us) at least some hint as to who threw the error and why.
I'm attaching a screen-shot of the result on my own site.
Attachments
Change History
SteveBooth — 3 years ago
-
attachment
404Enhancement.jpg
added
Screen shot of suggested 404 format