Index: .htaccess =================================================================== RCS file: /cvs/drupal/drupal/.htaccess,v retrieving revision 1.85 diff -u -F^f -r1.85 .htaccess --- .htaccess 18 May 2007 22:09:45 -0000 1.85 +++ .htaccess 1 Jul 2007 22:54:33 -0000 @@ -7,6 +7,18 @@ Order allow,deny +# The following 3 lines prevents Drupal from handling 404 errors for some +# flat files. The idea is to avoid the performance cost of doing a full +# Drupal bootstrap. +# +# You must uncomment the corresponding the RewriteCond line later in this +# file as well as those in settings.php +# + + ErrorDocument 404 default + +# + # Don't show directory listings for URLs which map to a directory. Options -Indexes @@ -86,6 +98,12 @@ # the rewrite rules are not working properly. #RewriteBase /drupal + # Uncomment the following line to save server and bandwidth resources. + # You must uncomment the corresponding FilesMatch line earlier in this file + # as well as those in settings.php + # + RewriteCond %{REQUEST_URI} !\.(png|gif|s?html|jpe?g|css|js|cgi|ico|swf|flv)$ + # Rewrite URLs of the form 'index.php?q=x'. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d Index: sites/default/default.settings.php =================================================================== RCS file: /cvs/drupal/drupal/sites/default/default.settings.php,v retrieving revision 1.2 diff -u -F^f -r1.2 default.settings.php --- sites/default/default.settings.php 17 Jun 2007 10:45:35 -0000 1.2 +++ sites/default/default.settings.php 1 Jul 2007 22:54:33 -0000 @@ -136,6 +136,24 @@ ini_set('session.use_trans_sid', 0); ini_set('url_rewriter.tags', ''); + +/** + * The following 4 lines prevents Drupal from handling 404 errors for some + * flat files. The idea is to avoid the performance cost of doing a full + * Drupal bootstrap. + * + * Uncomment the following 4 lines to save server and bandwidth resources. + * + * You must uncomment the corresponding RewriteCond and FilesMatch lines + * in .htaccess as well + */ + +if (preg_match("/\.(png|gif|s?html|jpe?g|css|js|cgi|ico|swf|flv)$/", $_SERVER['REQUEST_URI'])) { + header('HTTP/1.0 404 Not Found'); + print "Page not found."; + exit(); +} + /** * Drupal automatically generates a unique session cookie name for each site * based on on its full domain name. If you have multiple domains pointing at