I want to use sub routes with Slim Framework v3.2.0 like so:
- www.test.com/ <-- index page
- www.test.com/foodtype/ <-- separate page
- www.test.com/foodtype/page/ <-- subcategory of foodtype
As I understand it, only one get can be called. Currently I have this in my routes.php:
$app->get('/', function () {
// Load index page
});
$app->get('/{foodtype}', function ($request, $response, $args) {
// Load page based on the value of $args['foodtype']
});
How can I add the separate optional route for page1?
I've tried:
$app->get('/{foodtype}/{page}', function ($request, $response, $args) {
// Load page based on the value of $args['foodtype'] and $args['page']
});
This causes a 'page not found' error. I presume I need to escape the optional '/' too?