[drupal-devel] [bug] Fix 404 handling without clean URLs

killes drupal-devel at drupal.org
Fri Aug 19 13:54:01 UTC 2005

Issue status update for 
Post a follow up: 

 Project:      Drupal
 Version:      cvs
 Component:    base system
 Category:     bug reports
 Priority:     normal
 Assigned to:  Steven
 Reported by:  Steven
 Updated by:   killes at www.drop.org
-Status:       active
+Status:       patch (code needs work)

Steven what's up with this?

killes at www.drop.org

Previous comments:

Sun, 28 Nov 2004 15:08:31 +0000 : Steven

Attachment: http://drupal.org/files/issues/404.patch (1.07 KB)

When clean urls are enabled, non-existant pages are rewritten to
www.site.com/?q=non/existant. The menu handler will throw a 404 on the
non-existant Drupal path.

However, if clean urls are not active, then the 404 page (index.php) is
called as is. $GET['q'] will be empty, and the front page will be shown
without any indication of the 404 or without a log entry in the
watchdog. Note that this only happens if .htaccess is being read, but
mod_rewrite is not present or enabled. Not too common, but still a bug.

The attached patch fixes this problem by checking for a 404 in
index.php and calling drupal_not_found() if needed. It also sets
$_GET['q'] to request_uri(), so the 404'd URL shows up correctly in the
watchdog (same as the rewrite rule).

This should go in 4.5 as well as HEAD. Patch is for HEAD, but it should
apply to 4.5.


Sun, 28 Nov 2004 15:17:22 +0000 : Steven

An alternative solution is to drop the ErrorDocument 404 from .htaccess,
then the web server will handle them if there are no clean URLs. However
I think the intended behaviour is for Drupal to log all 404s.


Sun, 13 Mar 2005 20:44:58 +0000 : killes at www.drop.org

Doesn't apply anymore.

More information about the drupal-devel mailing list