create custom 404 page in laravel

create custom 404 page in laravel

In this post we will give you information about create custom 404 page in laravel. Hear we will give you detail about create custom 404 page in laravelAnd how to use it also give you demo for it if it is necessary.

In this tutorials, i am showing to how to manage 404 error in your laravel project. Because when you upload your laravel site in live and if you not create any 404 page and you not manage it right way then it more effect in your site SCO.

When any user visit your site and he/she try to pass rong routes or paramiters in URL, then your site showing error and google considers it your site URL breck and it’s effect in your site SCO

So, how to manage that type problem in laravel in right way

step : 1 create new laravel project

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

step : 3 change in app/Exceptions/Handler.php file

 * Render an exception into an HTTP response.
 * @param  IlluminateHttpRequest  $request
 * @param  Exception  $exception
 * @return IlluminateHttpResponse
public function render($request, Exception $exception)
        switch ($exception->getStatusCode()) 
            // not found
            case 404:
            return redirect()->route('notfound');

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

                return $this->renderHttpException($e);
            return parent::render($request, $exception);

step : 3 create route for page not found

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

step : 4 create pagenotfound() in HomeController

public function pagenotfound()
    return view('errors.pagenotfound');

step : 4 create 404 page in resources/views/errors folder

<!DOCTYPE html>
	<title>Page Not Found</title>
	<h1>Sorry, Page Not Found</h1>

I hope this tutorials is helpful to you….

Hope this and post will helped you for implement create custom 404 page in laravel. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

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

  +  85  =  86

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US