Laravel additional route parameters
1 answer
By default, the route parameter cannot contain any forward slashes, because multiple route parameters or segments are separated by slashes.
If you have a finite number of path levels, you can do this:
Route::get('dashboard/{path1?}/{path2?}/{path3?}', function($path1 = null, $path2 = null, $path3 = null)
However, this is not very elegant and dynamic, and your example hints that there can be many levels of the path. You can use a where constraint to allow slashes in the route parameter. So this route will basically catch anything that starts withdashboard
Route::get('dashboard/{path?}', function($path= null){
return $path;
})->where('path', '(.*)');
+7
source to share