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) { if($this->isHttpException($exception)) { switch ($exception->getStatusCode()) { // not found case 404: return redirect()->route('notfound'); break; // 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 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> <html> <head> <title>Page Not Found</title> </head> <body> <h1>Sorry, Page Not Found</h1> </body> </html>
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