Issue
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.
Solution
Solution #1 - Via Exception Handler (404)
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);
}
Solution #2 - Via Route
routes/web.php
// Last line!
Route::any('{any}', function () {
return redirect('/');
});
Answered By - Wahyu Kristianto
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.