Create a module urlManager rule in Yii
I'm trying to set a module up so any actions called without a controller will execute on DefaultController. I've managed to get this working by 开发者_高级运维adding a urlManager rule to my site config file that redirects to the appropriate controller.
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
...
'module/'=>'module/default/',
...
),
'showScriptName'=>false,
),
This works fine, but I would rather have the rule contained within the module (either in < Module >Module.php) or in the modules portion of the config file.
// included modules
'modules'=>array(
'module',
),
Is there any way to accomplish this?
Since most of the config file is just a big array, it would be hard to break up rules into different places. You could create just the rules array programmatically outside the config block and then your urlManager config would look something like:
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>$rules,
'showScriptName'=>false,
There is also a CUrlManager::addRules method but you would have to see if where you want to put it would work with the bootstrap process.
精彩评论