diff --git a/build/router/controller/js.php b/build/router/controller/js.php index 591a94d..96b5115 100644 --- a/build/router/controller/js.php +++ b/build/router/controller/js.php @@ -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'; } diff --git a/build/router/controller/page.php b/build/router/controller/page.php index 18a92a1..588b471 100644 --- a/build/router/controller/page.php +++ b/build/router/controller/page.php @@ -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); diff --git a/config/routes.json b/config/routes.json index 8658fbc..4351cc3 100644 --- a/config/routes.json +++ b/config/routes.json @@ -24,7 +24,7 @@ "methods": ["GET"], "controller": "page:load", "arguments": { - "page": "[a-z]+", + "page": "\\w+", "uri": ".*" } }, diff --git a/public_html/page/404.php b/public_html/page/404.php new file mode 100644 index 0000000..4daa28d --- /dev/null +++ b/public_html/page/404.php @@ -0,0 +1,16 @@ + + + + + + + + + Erreur 404 - Ressource introuvable + + + La ressource est introuvable. + + + + \ No newline at end of file