+added page 404

This commit is contained in:
xdrm-brackets 2018-02-20 17:45:02 +01:00
parent 7484bea239
commit ed374a882c
4 changed files with 22 additions and 11 deletions

View File

@ -41,10 +41,8 @@
* *
*/ */
public function bundle(){ public function bundle(){
if( is_null($this->page) ){ if( is_null($this->page) )
http_response_code(404); include __PUBLIC__.'/page/404.php';
die();
}
/* (1) Extract /public_html/js/ all .js files */ /* (1) Extract /public_html/js/ all .js files */
$js_scripts = glob(__PUBLIC__.'/js/bundle/'.$this->page.'@*.js'); $js_scripts = glob(__PUBLIC__.'/js/bundle/'.$this->page.'@*.js');
@ -61,8 +59,7 @@
} }
/* (3) If nothing found */ /* (3) If nothing found */
http_response_code(404); include __PUBLIC__.'/page/404.php';
die();
} }

View File

@ -28,10 +28,8 @@
$page_fname = __PUBLIC__."/page/".$this->pagename.".php"; $page_fname = __PUBLIC__."/page/".$this->pagename.".php";
/* (2) If page does not exist -> 404 */ /* (2) If page does not exist -> 404 */
if( !file_exists($page_fname) ){ if( !file_exists($page_fname) )
http_response_code(404); include __PUBLIC__.'/page/404.php';
die('Page not found');
}
/* (3) Set URI arguments */ /* (3) Set URI arguments */
$_GET['uri'] = explode('/', $this->uri); $_GET['uri'] = explode('/', $this->uri);

View File

@ -24,7 +24,7 @@
"methods": ["GET"], "methods": ["GET"],
"controller": "page:load", "controller": "page:load",
"arguments": { "arguments": {
"page": "[a-z]+", "page": "\\w+",
"uri": ".*" "uri": ".*"
} }
}, },

16
public_html/page/404.php Normal file
View File

@ -0,0 +1,16 @@
<?php http_response_code(404); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Erreur 404 - Ressource introuvable</title>
</head>
<body>
La ressource est introuvable.
</body>
</html>
<?php die(); ?>