I have a Lumen project (Lumen 5.2) and I need to do two different things for two identical urls except for an ending slash '/'. For example:
http://example.com/some/path --> Show a resource named 'path'
http://example.com/some/path/ --> List the content of the 'path' folder
But I didn't found a way to write routes able to capture such difference.
I tried with this:
$app->get('/{p:.*}', function ($p) use ($app) {
return 'Case 1: ' . $p;
});
$app->get('/{p:.*}/', function ($p) use ($app) {
return 'Case 2: ' . $p;
});
But both urls (/some/path
and /some/path/
) are captured by the last route and $p
is some/path
in both cases, so I can't know what url it was.
Is there a way to solve this?