3

Can anyone help me to create a custom 404 page in laravel 5.7, i am new to laravel so it'd great if you tell me the flow for this.

Thanks

3 Answers 3

7

Create 404.blade.php file in errors folder inside your views and make customizations that you want.

OR

You can also use vendor:publish command to publish all the errors blade defined in core.

php artisan vendor:publish --tag=laravel-errors 

This will create an errors folder in your views directory and in it there will be all error blade files. You can customize 404.blade.php in it.

Sign up to request clarification or add additional context in comments.

Comments

2

@Kamal's solution is good if you want to use a static 404 file. For more customization you can create a proper 404 controller.

To do so first create a controller and method for handling the 404 page (or add a method to an existing controller). Then, tell Laravel to redirect to that controller if no other route was found by adding this at the end of your routes\web.php file. Here's an example:

Route::get('404', 'PageController@render_404_page'); Route::fallback(function () { return redirect('404'); }); 

This gives you the freedom to add more logic to 404 pages.

Comments

0

Laravel makes it easy to display custom error pages for various HTTP status codes.

You find the updated documentaion here.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.