To get a custom 404 and 503 pages in Laravel 5 is very easy. Simply do 2 things to get it working:
1. Create a folder in views called errors and a blade called 404.blade.php and add your custom html in there.
2. Replace the render function with the one below in /app/exceptions/Handler.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
/** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Exception $e * @return \Illuminate\Http\Response */ public function render($request, Exception $e) { if ($this->isHttpException($e)) { return $this->renderHttpException($e); } else { return parent::render($request, $e); } } |
The go to check it here: https://localhost/404 should look like this: