drupal_not_found

5 common.inc drupal_not_found()
6 common.inc drupal_not_found()
7 common.inc drupal_not_found()
8 common.inc drupal_not_found()

Generates a 404 error if the request can not be handled.

Related topics

17 calls to drupal_not_found()

File

includes/common.inc, line 373
Common functions that many Drupal modules will need to reference.

Code

function drupal_not_found() {
  drupal_set_header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');

  watchdog('page not found', check_plain($_GET['q']), NULL, WATCHDOG_WARNING);

  // Keep old path for reference, and to allow forms to redirect to it.
  if (!isset($_REQUEST['destination'])) {
    $_REQUEST['destination'] = $_GET['q'];
  }

  $path = drupal_get_normal_path(variable_get('site_404', ''));
  if ($path && $path != $_GET['q']) {
    // Set the active item in case there are tabs to display, or other
    // dependencies on the path.
    menu_set_active_item($path);
    $return = menu_execute_active_handler($path);
  }

  if (empty($return) || $return == MENU_NOT_FOUND || $return == MENU_ACCESS_DENIED) {
    drupal_set_title(t('Page not found'));
    $return = t('The requested page could not be found.');
  }

  // To conserve CPU and bandwidth, omit the blocks.
  print theme('page', $return, FALSE);
}

Comments

drupal_access_denied

Use drupal_access_denied() to display a 403, instead of a 404.

Login or register to post comments