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

View File

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

View File

@ -24,7 +24,7 @@
"methods": ["GET"],
"controller": "page:load",
"arguments": {
"page": "[a-z]+",
"page": "\\w+",
"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(); ?>