phplaravelhttp-status-code-404laravel-authentication

Custom 404 laravel


If we just create a 404.blade.php page in resources/views/error it will work fine, but Auth() won't work on 404 page, to solve that if we follow the solution available on stackoverflow the Laravel auth errors will stop working. I use the following solution to do the work.


Solution

  • Create custom view

    resources/views/errors/404.blade.php

    in route.php

    Route::any('{catchall}', 'PageController@notfound')->where('catchall', '.*');
    

    create PageController and add this function

    public function notfound() 
    { 
        return view('errors.404'); 
    }