function drupal_fast_404

Returns a simple 404 Not Found page.

If fast 404 pages are enabled, and this is a matching page then print a simple 404 page and exit.

This function is called from drupal_deliver_html_page() at the time when a a normal 404 page is generated, but it can also optionally be called directly from settings.php to prevent a Drupal bootstrap on these pages. See documentation in settings.php for the benefits and drawbacks of using this.

Paths to dynamically-generated content, such as image styles, should also be accounted for in this function.

1 call to drupal_fast_404()
drupal_deliver_html_page in includes/
Packages and sends the result of a page callback to the browser as HTML.


includes/, line 2980


function drupal_fast_404() {
    $exclude_paths = variable_get('404_fast_paths_exclude', FALSE);
    if ($exclude_paths && !preg_match($exclude_paths, $_GET['q'])) {
        $fast_paths = variable_get('404_fast_paths', FALSE);
        if ($fast_paths && preg_match($fast_paths, $_GET['q'])) {
            drupal_add_http_header('Status', '404 Not Found');
            $fast_404_html = variable_get('404_fast_html', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" ""><html xmlns=""><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "@path" was not found on this server.</p></body></html>');
            // Replace @path in the variable with the page path.
            print strtr($fast_404_html, array(
                '@path' => check_plain(request_uri()),

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.