标签云

微信群

扫码加入我们

WeChat QR Code

I want to use sub routes with Slim Framework v3.2.0 like so:www.test.com/ <-- index pagewww.test.com/foodtype/ <-- separate pagewww.test.com/foodtype/page/ <-- subcategory of foodtypeAs 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?