I have some legacy routes and I should redirect all of them to page 404. All of them have admin and user at the beginning. What are best practices to do this?
e.g. is there anyway to use regular expresion?
I have some legacy routes and I should redirect all of them to page 404. All of them have admin and user at the beginning. What are best practices to do this?
e.g. is there anyway to use regular expresion?
So Laravel can be a bit vague in terms of documentation about catch-all routes, you can use the following (untested) to catch any optional route below a given route and redirect back to a 404 page.
// Redirect all /admin routes
Route::get('admin/{any?}', function ($any = null) {
return redirect('404');
})->where('any', '.*');
// Redirect all /user routes
Route::get('user/{any?}', function ($any = null) {
return redirect('404');
})->where('any', '.*');
Personally I'd probably set up a rewrite to do this via a 301 permanent redirect before it even hits Laravel, but this should help you out in the meantime.