summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author53hornet <atc@53hor.net>2021-12-11 16:09:31 -0500
committer53hornet <atc@53hor.net>2021-12-11 16:09:31 -0500
commit59ca721c6aa954bb3cd3c7511893a3080d8df832 (patch)
treef091b782736bc92862c7cf37248215db6a147f0c
parent58a720d84854b7a63ebeacbb58b1f87baa1eaf9f (diff)
download53hor-59ca721c6aa954bb3cd3c7511893a3080d8df832.tar.xz
53hor-59ca721c6aa954bb3cd3c7511893a3080d8df832.zip
feat: better 404 handling
-rw-r--r--includes/404.php5
-rw-r--r--index.php9
2 files changed, 11 insertions, 3 deletions
diff --git a/includes/404.php b/includes/404.php
new file mode 100644
index 0000000..dbf344f
--- /dev/null
+++ b/includes/404.php
@@ -0,0 +1,5 @@
+<h1>Not Found</h1>
+
+<p>
+ That's been moved or is otherwise missing, sorry! <a href="/">Check out my other stuff</a>.
+</p>
diff --git a/index.php b/index.php
index 5e5e92d..4cbfc09 100644
--- a/index.php
+++ b/index.php
@@ -3,12 +3,15 @@ include('./includes/head.php');
$page = strtok($_SERVER['REQUEST_URI'], '/');
-if (!empty($page) && $page[0] >= '0' && $page[0] <= '9') {
+
+if (empty($page)) {
+ include('./includes/render_index.php');
+} else if (!empty($page) && $page[0] >= '0' && $page[0] <= '9' && is_readable("./posts/$page.php")) {
include("./posts/$page.php");
-} else if (!empty($page)) {
+} else if (!empty($page) && is_readable("./posts/$page.php")) {
include("./pages/$page.php");
} else {
- include('./includes/render_index.php');
+ include('./includes/404.php');
}
include('./includes/foot.php');