Custom 404 page template in Drupal

A simple snippet to define a custom 404 and 403 theme suggestion in Drupal:

function YOURTHEME_preprocess_page(&$vars) {
  $header = drupal_get_http_header("status");
  if($header == "404 Not Found") {
    $vars['theme_hook_suggestions'][] = 'page__404';
  }
  if($header == "403 Forbidden") {
    $vars['theme_hook_suggestions'][] = 'page__403';
  }
}

The template file should be named page--404.tpl.php and clear the cache and this should work.

Source: https://www.drupal.org/node/15366#comment-7218780