# Add prefix to all routes

**URL:** <https://discourse.slimframework.com/t/add-prefix-to-all-routes/515>\
**Category:** Questions\
**Created:** [July 17, 2016, 6:35am UTC](https://discourse.slimframework.com/t/add-prefix-to-all-routes/515 "2016-07-17T06:35:09Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![iansltx](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/iansltx/32/153_2.png) [@iansltx](https://discourse.slimframework.com/u/iansltx)\
**Post date:** [July 17, 2016, 8:50pm UTC](https://discourse.slimframework.com/t/add-prefix-to-all-routes/515/3 "2016-07-17T20:50:00Z")

</div>

You can actually use $app-\>group($path, $callable) to achieve this. Inside the callable, you can treat $this like $app outside the callable. So you could revise your example to:

```
$app->group('/users', function() {
    $this->get('/{id}', 'UserController:getUser');
    $this->get('', 'UserController:getUsers');
});
```

---

_[View the full topic](https://discourse.slimframework.com/t/add-prefix-to-all-routes/515)._
