Laravel 5.7 custom 404 Error Page Using Exception Handlers

Today, We want to share with you Laravel 5.7 custom 404 Error Page Using Custom Exception Handlers.In this post we will show you php – Laravel 5.7 error 404 handling page location, hear for How to create custom 404 error page in Laravel 5.7? we will give you demo and example for implement.In this post, we will learn about Creating A Laravel 404 Page Using Custom Exception Handlers with an example.

Laravel 5.7 custom 404 Error Page Using Custom Exception Handlers

There are the Following The simple About Laravel 5.7 custom 404 Error Page Using Custom Exception Handlers Full Information With Example and source code.

As I will cover this Post with live Working example to develop Laravel 5.7 Logs and Errors Example From Scratch, so the laravel 5.7 create custom 404 page for this example is following below.

Step 1: Setting on Handler.php File

app/Exceptions/Handler.php

public function render($request, Exception $exception)
{
	if($this->isHttpException($exception)){
		switch ($exception->getStatusCode()) {
			case 404:
				return redirect()->route('404');
				break;
			case 405:
				return redirect()->route('405');
				break;
			case 302:
				return redirect()->route('302');
				break;	
		}
	}
	return parent::render($request, $exception);
}

Step 2: Define Laravel Error Route

routes/web.php

//php - laravel 5.7 custom 404 Error Page
Route::get('404',['as'=>'404','uses'=>'laravelErrorController@errorCode404']);

Route::get('405',['as'=>'405','uses'=>'laravelErrorController@errorCode405']);

Step 3: Laravel Add Controller

app/Http/Controllers/laravelErrorController.php

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

Step 4: Add Laravel Blade Files

resources/views/errors/404.blade.php




	Laravel 5.7 - create custom 404 error page
    
    
    
        body{
          margin-top: 150px;
            background-color: #c6cc36;
        }
        .live-error-card{
          background-color: #fff;
          box-shadow: 0px 11px 11px -11px #3d3d3d;
        }
        .live-error-card h1{
          font-weight: bold;
          color: #4d4d4d;
          font-size: 100px;
          text-shadow: 3px 5px 6px #c60000;
        }
        .live-error-card h6{
          color: #42494F;
        }
        .live-error-card p{
          color: #9695c6;
          font-size: 18px; 
        }
    


    

Laravel 5.7 - create custom 404 error page

404

Page not found - pakainfo.com

Pakainfo is the most popular Programming & Web Development blog.Pakainfo, Tutorials Our mission is to provide the best online resources on programming and web development. We deliver the useful and best tutorials for web professionals — developers, programmers, freelancers and site owners. Any visitors of this site are free to browse our tutorials, live demos and download scripts.

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 Laravel 5.7 custom 404 Error Page Using Custom Exception Handlers.
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