Create Custom 404 Error page in laravel Example

Today, We want to share with you Create Custom 404 Error page in laravel Example.In this post we will show you How to create custom 404 error page in Laravel, hear for Creating A Laravel 404 Page Using Custom Exception Handlers we will give you demo and example for implement.In this post, we will learn about laravel redirect if route not found with an example.

Create Custom 404 Error page in laravel Example

There are the Following The simple About Create Custom 404 Error page in laravel Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop How to create custom 404 page in laravel, so the laravel 5 custom 404 for this example is following below.

step : 1 Install laravel 5.6 project

create new laravel project

composer create-project --prefer-dist laravel/laravel simplelaravelblog

step : 2 change in Handler File

app/Exceptions/Handler.php file

isHttpException($exception))
    {
        switch ($exception->getStatusCode()) 
            {
            //here call not found
            case 404:
            return redirect()->route('notfound');
            break;

            //Laravel internal error
            case '500':
            return redirect()->route('notfound');
            break;

            default:
                return $this->renderHttpException($e);
            break;
        }
    }
    else
    {
            return parent::render($request, $exception);
    }
}

step : 3 create route

Make a Laravel Route page not found

Route::get('notpagefound', ['as' => 'notfound', 'uses' => 'ProductController@notpagefound']);

step : 4 create notpagefound()

app/http/ProductController.php

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

step : 5 Laravel create 404 page

resources/views/errors folder




    Page Not Found - Creating A Laravel 404 Page Using Custom Exception Handlers


    

Sorry, Page Not Found

Page not found - YourWebsite.com
Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Create Custom 404 Error page in laravel Example.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment