The Wrong Controller Is Invoked

I recently moved my yii application to another server with a different apache configuration. Now when I try to access a controller inside a module, e.g. /module/controller/action, the wrong controller (/controller/action) will be invoked. It is as if the framework is ignoring /module/.

If I move the app to a third sever which has similar apache setup as the first server, it runs without any issue. So I suspect it is something with the apache configuration that causes the framework to construct the wrong path.

Any help would be greatly appreciated.


I’ll check:

  • url format in config/main.php;

  • Yii::app()->basePath in a controller;

  • Format of Yii::app()->createUrl parameters (if you build url using this method)

Thanks for the suggestion.

Even if I am not using clean url and use the standard /index.php?r= format, the same thing happens. What makes me think the problem lies with the server/apache setting is that, if I move the app to another server with a standard lampp setup, the app runs normally.

I have been tracing the program to CWebApplication.php in yii/framework/web. Seems that it can break down the $route ok, and try to call createController("controller/action", "mymodule"). But when it gets to $basePath=$owner->getControllerPath(), it gets the wrong path. Instead of returning "path-to-myapp/protected/modules/mymodule/controllers" it returns "path-to-myapp/protected/controllers".


Why don’t you create url using

$this->createUrl(’<module>/<controller>/<action>’) ?

where $this is a Controller object.

Problem solved by installing a fresh copy of yii.