# \[Solved\] \[CakePHP-4.X\] Reverse routing issue

**URL:** <https://discourse.cakephp.org/t/solved-cakephp-4-x-reverse-routing-issue/12051>\
**Category:** Need Help\
**Created:** [June 5, 2024, 7:59am UTC](https://discourse.cakephp.org/t/solved-cakephp-4-x-reverse-routing-issue/12051 "2024-06-05T07:59:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chocanewb](https://avatars.discourse-cdn.com/v4/letter/c/da6949/32.png) [@Chocanewb](https://discourse.cakephp.org/u/Chocanewb)\
**Post date:** [June 5, 2024, 7:59am UTC](https://discourse.cakephp.org/t/solved-cakephp-4-x-reverse-routing-issue/12051/1 "2024-06-05T07:59:26Z")

</div>

I am experiencing problems with routing on cakephp 4.x  
I have a connector in routes.php like this :

```auto
$routes->connect(
        '/achat-vente-location/licences-{type}/departement/{slug}/{id}', 
        [
            'controller' => 'Licences', 
            'action' => 'departement', 
            'prefix' => null
        ]
    )
    ->setPatterns(
        [
            'id' => '[0-9]+', 
            'type' => 3
        ]
    )
    ->setPass(
        [
            'id', 
            'type',
            'slug'
        ]
    );

```

In my view, I am trying to generate the correct url like this :

```auto
Router::url([
            'controller' => 'Licences', 
            'action' => 'departement', 
            'type' => 3, 
            'slug' => 'Slug', 
            'id' => 33321
        ]);

```

But it does not generate the good URL and I do not know why. I get this URL :

```auto
https://localhost/licences/departement

```

What is expected :

```auto
https://localhost/achat-vente-location/licences-3/departement/Slug/33321

```

Thanks to everyone for your help !

---

<div class="post-metadata">

**Author:** ![Chocanewb](https://avatars.discourse-cdn.com/v4/letter/c/da6949/32.png) [@Chocanewb](https://discourse.cakephp.org/u/Chocanewb)\
**Post date:** [June 5, 2024, 8:58am UTC](https://discourse.cakephp.org/t/solved-cakephp-4-x-reverse-routing-issue/12051/2 "2024-06-05T08:58:56Z")

</div>

Problem solved !

You have to mention the ‘prefix’ parameter in the Router::url() function like this :

```auto
Router::url([
    'controller' => 'Licences', 
    'action' => 'departement',
    'prefix' => null, 
    'type' => 3, 
    'slug' => 'Slug', 
    'id' => 33321
]);

```
