404 errordocument handling
Posted: Tue Dec 09, 2003 6:37 pm
Hi,
First up thanks for a great blog
I've just been playing with s9y for a few days now and all is great apart from the following:
If a user enters an invalid (404) URI, the code in index.php appears to still divert the user to the index page instead of displaying the 404 error message as it presumably is supposed to. From what I can see this is because of the following code from index.php - line 132 onwards:
I believe this code should evaluate to false if an invalid URI is entered but instead always evaluates true as long as the URI contains a forward slash (/) - which is always given the way most web browsers work.
For example this URI:
http://blog.munk.nu/nonexistent
should presumably invoke the 'catchall' code in index.php:
however it doesn't and instead displays the 'default' page listing.
From what I can tell this is because of the pcre '?' in the regexps in the first 2 preg_match statements - changing the code to this has the desired effect:
ie invalid URIs DO invoke the 404 error code with this ammendment.
Should the '?' be removed or just be escaped? Or am I totally wrong?
TIA
First up thanks for a great blog
I've just been playing with s9y for a few days now and all is great apart from the following:
If a user enters an invalid (404) URI, the code in index.php appears to still divert the user to the index page instead of displaying the 404 error message as it presumably is supposed to. From what I can see this is because of the following code from index.php - line 132 onwards:
Code: Select all
} else if (preg_match('@/categories/(.*)@', $uri, $matches) ||
preg_match('@/(index\.(php|html))?@', $uri) ||
preg_match('@/(' . preg_quote($serendipity['indexFile']) . ')?@', $uri)) {
For example this URI:
http://blog.munk.nu/nonexistent
should presumably invoke the 'catchall' code in index.php:
Code: Select all
} else {
printf(DOCUMENT_NOT_FOUND, $uri);
}
From what I can tell this is because of the pcre '?' in the regexps in the first 2 preg_match statements - changing the code to this has the desired effect:
Code: Select all
} else if (preg_match('@/categories/(.*)@', $uri, $matches) ||
preg_match('@/(index\.(php|html))@', $uri) ||
preg_match('@/(' . preg_quote($serendipity['indexFile']) . ')@', $uri)) {
Should the '?' be removed or just be escaped? Or am I totally wrong?
TIA