# Fast Route Bad Route Exception

**URL:** <https://discourse.slimframework.com/t/fast-route-bad-route-exception/1492>\
**Category:** Questions\
**Created:** [May 14, 2017, 8:14pm UTC](https://discourse.slimframework.com/t/fast-route-bad-route-exception/1492 "2017-05-14T20:14:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlazzeri](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@mlazzeri](https://discourse.slimframework.com/u/mlazzeri)\
**Post date:** [May 14, 2017, 8:14pm UTC](https://discourse.slimframework.com/t/fast-route-bad-route-exception/1492/1 "2017-05-14T20:14:51Z")

</div>

I am getting the following error

Static route “/pacientes/nuevoNumero” is shadowed by previously defined variable route “/pacientes/([^/]+)” for method "GET

when I trying to get the following routes  
api/usuarios/1 and api/pacientes/1

```
#Users routes
$app->get('/usuarios/', 'UserController:GetAll')->add('LoginMiddleware');
$app->get('/usuarios/{id}', 'UserController:GetById')->add('LoginMiddleware');
$app->post('/usuarios/', 'UserController:Add')->add('LoginMiddleware');
$app->post('/usuarios/login', 'UserController:Login')->add('LoginMiddleware');
$app->put('/usuarios/{id}', 'UserController:Edit')->add('LoginMiddleware');
$app->delete('/usuarios/{id}', 'UserController:Remove')->add('LoginMiddleware');

#Patients routes
$app->get('/pacientes/{id}', 'PatientController:GetById')->add('LoginMiddleware');
$app->get('/pacientes/', 'PatientController:GetAll')->add('LoginMiddleware');
$app->get('/pacientes/nuevoNumero', 'PatientController:NewNumber')->add('LoginMiddleware');
$app->post('/pacientes/porNombre', 'PatientController:GetByName')->add('LoginMiddleware');
$app->post('/pacientes/porNumero', 'PatientController:GetByNumber')->add('LoginMiddleware');
$app->post('/pacientes/porDocumento', 'PatientController:GetByDocument')->add('LoginMiddleware');

```

could anyone help me to find the issue?  
thanks!

---

<div class="post-metadata">

**Author:** ![silentworks](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/silentworks/32/10_2.png) [@silentworks](https://discourse.slimframework.com/u/silentworks)\
**Post date:** [May 14, 2017, 8:49pm UTC](https://discourse.slimframework.com/t/fast-route-bad-route-exception/1492/2 "2017-05-14T20:49:27Z")

</div>

Try reordering your routes like below.

```
$app->get('/pacientes/nuevoNumero', 'PatientController:NewNumber')->add('LoginMiddleware');
$app->get('/pacientes/{id}', 'PatientController:GetById')->add('LoginMiddleware');
$app->get('/pacientes/', 'PatientController:GetAll')->add('LoginMiddleware');
```

---

<div class="post-metadata">

**Author:** ![mlazzeri](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@mlazzeri](https://discourse.slimframework.com/u/mlazzeri)\
**Post date:** [May 19, 2017, 11:19pm UTC](https://discourse.slimframework.com/t/fast-route-bad-route-exception/1492/3 "2017-05-19T23:19:48Z")

</div>

Hi @silentworks that was the solution, but why with that order now works?

---

<div class="post-metadata">

**Author:** ![damianopetrungaro](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/damianopetrungaro/32/236_2.png) [@damianopetrungaro](https://discourse.slimframework.com/u/damianopetrungaro)\
**Post date:** [May 19, 2017, 11:23pm UTC](https://discourse.slimframework.com/t/fast-route-bad-route-exception/1492/4 "2017-05-19T23:23:18Z")

</div>

@mlazzeri the router execute the callback of the very first valid path.

So: ‘/pacientes/{id}’ matched before of: ‘/pacientes/nuevoNumero’

---

<div class="post-metadata">

**Author:** ![mlazzeri](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@mlazzeri](https://discourse.slimframework.com/u/mlazzeri)\
**Post date:** [May 26, 2017, 2:48am UTC](https://discourse.slimframework.com/t/fast-route-bad-route-exception/1492/5 "2017-05-26T02:48:50Z")

</div>

thanks @damianopetrungaro
