I'm trying to create a Route in routes.php
that can handle optional unlimited sub-paths.
Route::get('/path/{url}', function($url){
echo $url;
});
The url's can be the following :
/path/part1
/path/part1/part2
/path/part1/part2/part3
etc.
But because of the /
in the url's with a subpath they don't match, so nothing happens. (The echo $url
is just for testing, of course).
I now use a trick to avoid this, by using ~
instead of /
for the subpaths, and then replace them afterwards, but I would like to know if there's a better way so I can just use /
in the URL's.
UPDATE
Found the solution, thanks to Mark :
Route::get('/path/{all}', function($url){
echo $url;
})->where('all', '.*');