1.20.x bootstrap.inc | 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 backdrop_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 Backdrop 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.
File
- includes/
bootstrap.inc, line 3662 - Functions that need to be loaded on every Backdrop request.
Code
function fast_404() {
$exclude_paths = settings_get('404_fast_paths_exclude', FALSE);
if ($exclude_paths && !preg_match($exclude_paths, $_GET['q'])) {
$fast_paths = settings_get('404_fast_paths', FALSE);
if ($fast_paths && preg_match($fast_paths, $_GET['q'])) {
backdrop_add_http_header('Status', '404 Not Found');
$fast_404_html = settings_get('404_fast_html', '<!DOCTYPE html><html><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())));
exit;
}
}
}