Laravel Custom 404 Error Page Example

Today, In this tutorial we explain you how to create custom create 404 and 500 error page in laravel. why we need to this error page? when visitor wrong type web url use in our site and that type of page not available in our site then we can display error page.

We can easy to makes custom error message using the exception handler. laravel provide exception handler class and it’s always check the all exceptions thrown. so it’s depending on the exception.

There are two methods aviailable in handle class. such as report and render. when report method handle the current request and return the without rendering an error page. the render method gives responds with an error message. it’s converting http response status from the exception and even sends it back to the browser.

Modify The Handler.php File

Let’s create a custom 404 page so we have to modify the render method in app/Exceptions/Handler.php file.

Create Blade Files

So finally, first we will create the new directory “resources/views/errors” and that directory in create a “resources/views/errors/404.blade.php” file. paste the below code in this file.

Leave a Reply

Your email address will not be published. Required fields are marked *