# Cakephp 2.x routing question

**URL:** <https://discourse.cakephp.org/t/cakephp-2-x-routing-question/982>\
**Category:** Need Help\
**Created:** [August 15, 2016, 6:34pm UTC](https://discourse.cakephp.org/t/cakephp-2-x-routing-question/982 "2016-08-15T18:34:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![LDSign](https://avatars.discourse-cdn.com/v4/letter/l/4bbf92/32.png) [@LDSign](https://discourse.cakephp.org/u/LDSign)\
**Post date:** [August 15, 2016, 6:34pm UTC](https://discourse.cakephp.org/t/cakephp-2-x-routing-question/982/1 "2016-08-15T18:34:55Z")

</div>

Hi

Is it possible to create a route with a wildcard “in the middle” which represents an unknown number of parameters when a named parameter is also at the end? The unknown parameters should be passed to $this-params-\>pass.

An example to make this a litte clearer. So the route is:

Router::connect(’/products/\*/:section’, array(‘controller’ =\> ‘categories’,‘action’ =\> ‘sets’,‘language’ =\> ‘eng’),array(‘named’ =\> array(‘section’)));

So \* represents a unknown count of parameters. It could be:

/products/cat1/cat2/cat3/:section

or

/products/cat1/:section

and so on.

This routing below would do the job, but it would be much nicer if the section is at the end.

Router::connect(’/products/:section/\*’, array(‘controller’ =\> ‘categories’,‘action’ =\> ‘sets’,‘language’ =\> ‘eng’),array(‘named’ =\> array(‘section’)));

Hope this is possible…

Thanks,  
Frank

---

<div class="post-metadata">

**Author:** ![reuben.helms](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/reuben.helms/32/172_2.png) [@reuben.helms](https://discourse.cakephp.org/u/reuben.helms)\
**Post date:** [August 16, 2016, 2:00am UTC](https://discourse.cakephp.org/t/cakephp-2-x-routing-question/982/2 "2016-08-16T02:00:54Z")

</div>

It’s been a while since I’ve played with CakePHP, but I’m not sure that it would be possible in the form you have it at the moment.

As an alternative, just use ‘/products/\*’ as the route, and have the controller inspect `$this->request->params['pass']` or `$this->passedArgs` to determine the value of the last segment, which could be the `section`.

Usage of `section` as a `named` would need to have the URL looking like `/products/cat1/section:MySection` to extract the value of the section.
