diff options
author | Parabola <dev@list.parabolagnulinux.org> | 2014-07-24 02:36:24 +0000 |
---|---|---|
committer | Parabola <dev@list.parabolagnulinux.org> | 2014-07-24 02:36:24 +0000 |
commit | a2e6a54a311bdc9fba52f028d2ea41a653491f8a (patch) | |
tree | 6f04ea9824e04341be320e739dbe0130ca6410cf /index.php | |
parent | 9a26239bb835d2d9687c04ad307901a40ddf45e1 (diff) |
handle 404, and serving itself correctly
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -11,6 +11,25 @@ $root = $_SERVER["DOCUMENT_ROOT"]; //$root = "/srv/http/repo/public/main"; $dirname = explode("?", $_SERVER["REQUEST_URI"], 2)[0]; +if (!is_dir($root.'/'.$dirname)) { + if (is_file($root.'/'.$dirname)) { + header('Content-Type: text/plain'); // gross, but if Nginx is "properly" configured, this only happens when serving itself, which is text + readfile($root.'/'.$dirname); + } else { + header("HTTP/1.0 404 Not Found"); + // This is the template used by Nginx internally; if you want something else, have Nginx intercept it. Separation of concerns. + ?><html> +<head><title>404 Not Found</title></head> +<body bgcolor="white"> +<center><h1>404 Not Found</h1></center> +<hr><center><?php echo $_SERVER["SERVER_SOFTWARE"]; ?></center> +</body> +</html> +<?php + } + exit(0); +} + function classify($root, $dirname, $filename) { global $repos_arch_project, $repos_arch_community, $repos_para_project, $repos_para_community; |