laravel 5 custom 404 laravel 5 custom 404 laravel laravel

laravel 5 custom 404


Go to resources/views/errors and create a 404.blade.php file with what you want on your 404 page and Laravel takes care of the rest.


if you want to have some global solution, you can do changes in /app/Exceptions/Handler.php by adding code bellow

public function render($request, Exception $e){    if ($this->isHttpException($e)) {        $statusCode = $e->getStatusCode();        switch ($statusCode) {            case '404':                return response()->view('layouts/index', [                    'content' => view('errors/404')                ]);        }    }    return parent::render($request, $e);}


In Laravel 5 you could simply put a custom 404.blade.php under resources/views/errors and that's it. For other errors like 500 you could try the following in your app/Exeptions/Handler.php:

public function render($request, Exception $e){    if ( ! config('app.debug') && ! $this->isHttpException($e)) {        return response()->view('errors.500');    }    return parent::render($request, $e);}

And do the same for 500 HTTP Exeptions