Skip to content
Advertisement

Show a 404 page if route not found in Laravel 5.1

I am trying to figure out to show 404 page not found if a route is not found. I followed many tutorials, but it doesn’t work. I have 404.blade.php in laravelresourcesviewserrors

Also in handler.php

JavaScript

If I enter wrong URL in browser, it returns a blank page. I have

JavaScript

in app.php.

Can anyone help me how to show a 404 page if route is not found? Thank you.

Advertisement

Answer

I recieved 500 errors instead of 404 errors. I solved the problem like this:

In the app/Exceptions/Handler.php file, there is a render function.

Replace the function with this function:

JavaScript

You can then use views that you save in views/errors/404.blade.php, and so on.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement