Laravel Redirect To Another URL / Web Page - HTTP Laravel Redirects

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.

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

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'=>'[email protected]']);

Route::get('405',['as'=>'405','uses'=>'[email protected]']);

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



	<title>Laravel 5.7 - create custom 404 error page</title>
    
    
    
        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; 
        }
    


    <div class="pakainfo container">
	<h1>Laravel 5.7 - create custom 404 error page</h1>
      <div class="row text-center">
        <div class="col-lg-6 offset-lg-3 col-sm-6 offset-sm-3 col-12 p-3 live-error-card">
          <div class="row">
            <div class="gst col-lg-8 pakainfo col-12 main-card col-sm-10 offset-lg-2 offset-sm-1">
              <h1 class="m-0">404</h1>
              <h6>Page not found - pakainfo.com</h6>
              <p>Pakainfo is the most popular Programming & Web Development blog.<span class="text-info">Pakainfo</span>, Tutorials <span class="text-info">Our mission is to provide the best online resources on programming and web development</span>. 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.</p>
            </div>
          </div>
        </div>
      </div>
    </div>


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.


Related FAQ

Here are some more FAQ related to this Article:

  1.   WordPress Plugin Activation Dependency Check
  2.   php check if string contains exist or not
  3.   Time-Range-Picker jquery time range picker example - jQueryUI TimeRangePicker
  4.   Jquery simple rating system with star
  5.   Simple Ajax Upload image using jQuery PHP
  6.   Create Custom 404 Error page in laravel Example
  7.   how to check a plugin is activated or not in wordpress
  8.   jquery Increment Animating Numbers Counting Up Example
  9.   Laravel MySQL Get Last Inserted ID
  10.   Two Way Data Binding using Angular Example