calling actions of default controller

Hi. I’ve found out a little unexpected code behaviour and I’m wondering what you guys know about it.

I have a default controller, e.g. PageController; it has several actions, e.g. actionIndex (default), actionOther.

http://mysite/ - calls actionIndex at PageController which is expectable

http://mysite/page/other - calls actionOther which too is expectable

but http://mysite/other cannot be resolved which is unexpectable.

What is expectable - is trying to find "actionOther" in default controller.

In order for “http://mysite/other” to search PageController for actionOther, you need to add the following rule to the ‘urlManager’ component in the main config file:


or you can make it specific to ‘other’


Go here to learn more.

Yes, CUrlManager can help. But why not make this work by default?

That’s a design decision. Yii always has to find the controller, that’s responsible for the current request. So your route can either contain:

  1. controllerID/actionID

  2. controllerID (default action of that controller is used)

  3. ‘’ (empty, meaning the default controller is used)

So if case 2. could be an actionID also, how should Yii know, what you’re talking about? (controllerID or actionID). Resolving the right controller in this case would be too expensive. Not to mention, how would you handle a conflict in that case?

But yii resolves conflicts of controllers and modules, doesn’t it?

If route cannot be resolved yii could try the first word as an action of default controller.

The fact is that Yii works differently.

Just fix it with urlManager and that’s all. The change you propose alter the logic of url resolving:

The logic is module/controller/view in that order

The module can be omitted for default controller.

If yii should find for default action in default controller if there is no controller specified, modules should be expected to resolve stuff like:

module/action as an action of the default controller in module.

The default controller is not so very default after all. That’s not right or is it?