recent post
Best Software Company in Dhaka - Top Firms & Rising Stars
Best Software Company in Dhaka, Top Software Firms in Dhaka, Dhaka Software Indu...
Top 4 best software companies in Dhaka, Bangladesh (2024)
Best Software Company in Dhaka, Top Software Firms in Dhaka, Dhaka Software Indu...
Easy way to find Facebook Page Categories
Easy way to find Facebook Page Categories. Why is it so difficult to find the ri...
How to redirect broken pages to home page in Laravel website...
How to redirect broken pages to home page in Laravel website
Corona: Creativity or captivity for us??
Corona virus has become the pandemic virus in the world. Day by day it is spread...
Every time while we do a Laravel project we face a issue. Such as if your enter this type of url "www.exmple.com/4567usdfhfsd". You will see error or 404 page. So, you can just redirect all this unnecessary link buy redirection them. So, what we need to do?
First you need to go to your {Laravel App}/app/Exceptions/Handler.php
Then find the public function render. You will see this code.
public function render($request, Throwable $exception) { return parent::render($request, $exception); }
You need add this line :
if ($exception instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) { return redirect('/'); }
So, The Code will be like :
public function render($request, Throwable $exception) { if ($exception instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) { return redirect('/'); } return parent::render($request, $exception); }
And we are done. Now if you enter "www.exmple.com/4567usdfhfsd". this type of url it will redirect to "www.exmple.com".
Thank you
Onecodesoft Team
0 Comments