Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 560
Akil Patel Avatar asked Oct 23 '25 11:10

Akil Patel


1 Answers

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'); 
}

like image 51
Kamlesh Paul Avatar answered Oct 26 '25 02:10

Kamlesh Paul



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!