From 7737a2e5adb830b9bd43f440adf5d6bde219029b Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Fri, 22 Feb 2013 01:56:22 +0100 Subject: [PATCH] Properly handle 404s --- public_html/modules/landing.php | 1 + public_html/rewrite.php | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/public_html/modules/landing.php b/public_html/modules/landing.php index d4eaf30..4dbe66f 100644 --- a/public_html/modules/landing.php +++ b/public_html/modules/landing.php @@ -19,6 +19,7 @@ try } catch (NotFoundException $e) { + http_status_code(404); $sPageContents = NewTemplater::Render("404", $locale->strings, array()); return; } diff --git a/public_html/rewrite.php b/public_html/rewrite.php index c47fea9..40b8b81 100644 --- a/public_html/rewrite.php +++ b/public_html/rewrite.php @@ -81,7 +81,16 @@ $router->routes = array( ) ); -$router->RouteRequest(); +try +{ + $router->RouteRequest(); +} +catch (RouterException $e) +{ + http_status_code(404); + $sPageTitle = "Page not found"; + $sPageContents = NewTemplater::Render("404", $locale->strings, array()); +} echo(NewTemplater::Render("layout", $locale->strings, array("contents" => $sPageContents, "title" => $sPageTitle, "padded" => (isset($router->uVariables['padded']) ? $router->uVariables['padded'] : true))));