Reputation: 41
I want to direct random link to only one view except that I've define
e.g : localhost:8000/abxcdss
It will go to a view or home page.
Upvotes: 0
Views: 227
Reputation: 9313
app/Exceptions/Handler.php
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
//
public function render($request, Exception $exception)
{
if ($exception instanceof NotFoundHttpException) {
return redirect('/');
}
return parent::render($request, $exception);
}
routes/web.php
// Last line!
Route::any('{any}', function () {
return redirect('/');
});
Upvotes: 1