I want to create default route for wrong url in laravel.if I have typed tst instead of test It should redirect to default url '/' is it possible to restrict wrong url in laravel I have the routes
Route::get('/', function () {
return view('welcome');
});
Route::get('/test', function () {
return view('welcome');
});
At the end of all routes, add following route:
Route::any('{any}', function () {
return redirect()->url('/');
});
Or you can write directly like:
Route::redirect('/{any}', '/', 301);
This will take any routes except listed one and redirect to url.