Prakhar Prakhar - 10 months ago 93
PHP Question

Laravel routing issue

I am using

framework. I've setup couple of
that take a parameter like{dir_name}
. When I pass in a dir which has childrens it considers it as another route. Is there a way to bypass it?

I'm using this code:

return $path;

When I use
it throws a
Symfony\Component\HttpKernel\ Exception\NotFoundHttpException

Answer Source

You can try using constraints on the route parameter with a regular expression.

Route::any('/route/{dir_name}', function ($dir_name) {
    return $dir_name;
})->where('dir_name', '.*');

See the docs section about route parameters, specifically the "Regular Expression Route Constraints" part.