From 072f9659de6ee16e546d9737171c819f9d7e3913 Mon Sep 17 00:00:00 2001 From: Rev Date: Wed, 22 Dec 2021 16:18:25 +0900 Subject: [PATCH] redirect bad routes to search page --- items/api/app/Exceptions/Handler.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/items/api/app/Exceptions/Handler.php b/items/api/app/Exceptions/Handler.php index b375c61..8d36be8 100644 --- a/items/api/app/Exceptions/Handler.php +++ b/items/api/app/Exceptions/Handler.php @@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Validation\ValidationException; use Laravel\Lumen\Exceptions\Handler as ExceptionHandler; use Symfony\Component\HttpKernel\Exception\HttpException; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Throwable; class Handler extends ExceptionHandler @@ -49,6 +50,9 @@ class Handler extends ExceptionHandler */ public function render($request, Throwable $exception) { + if ($exception instanceof NotFoundHttpException) { + return redirect('/search'); + } return parent::render($request, $exception); } }