Pretty advanced problems with CUrlManager

Ok so this is my routing settings:


  'event/cost/<cost>'=> 'event/index'








  'event/cost/<cost>/location/<locationSlug>' => 'event/index'

  'event/cost/<cost>/categories/<categories>' => 'event/index'

  'event/cost/<cost>/query/<query>' => 'event/index'

  'event/cost/<cost>/categories/<categories>/query/<query>' => 'event/index'





event/index is a filter and i want to be able to access it both by

  • event/cost/200/location/new-york

  • event/location/new-york

  • event/location/new-york/query/nightclub

well you get the idea?

the problem is, only the first 4 paths work.

if I, as an example, try

$this->createUrl('event/index', array(

  'locationSlug' => 'new-york',

  'query' => 'nightclub'


I don’t get “/location/new-york/query/nightclub” as expected, but instead the URL returned is "/location/new-york?query=nightclub.

A solution or idea on how to work around it is very much appreciated as I’m kinda on deadline with this particular part… Thanks!

edit: edited the routing to make it more readable

If everything goes to index, why not:


  'event/*'=> 'event/index'



hm, i wanted to filter what’s allowed in the urlManager but you’re probably right, will try it out!

Nope, the propositioned solution did not work. Since i also have this routing rule:

'event/v/<slug>' => 'event/view'

which apparently gets replaced…

And now the url looks like this: localhost/event/index?location=stockholm&query=fotboll

Any other proposed solutions?

You have to order the rules in a certain way.

Take a look at these 2 rules:



Now if you call createUrl() and you provide locationSlug, then the first rule will always match, no matter what other params you provide.

However, if the rules are ordered like this:



then the first rule will only match if at least locationSlug and query params are provided. So if you only provide locationSlug, then the second rule will match.