In slim 3 i'm trying to define a wildcard route - something to catch all url typos
Below my code
$app->get('/.*', function (Request $request, Response $response) {
$response->getBody()->write("MY MESSAGE");
return $response;
});
However all I get is a Page Not Found. With all the changes in version 3 have I missed something?
This works:
$app->get('/[{path:.*}]', function($request, $response, $path = null) {
return $response->write($path ? 'subroute' : 'index');
});
About optional part you can read here: http://www.slimframework.com/docs/objects/router.html#any-route and https://github.com/nikic/FastRoute/blob/master/README.md
Thank you.
It worked.
Most helpful comment
This works:
About optional part you can read here: http://www.slimframework.com/docs/objects/router.html#any-route and https://github.com/nikic/FastRoute/blob/master/README.md