Module Routing

Hi,

I created a module in Yii. The module is called "admin". Here are my routing problems: I have "Property" controller in the module. At the moment I have two actions there: actionIndex() and actionApprove().

When I go to /admin/property it calls the Index action, which is fine. But when I call /admin/property/approve, it calls the Index action again. Only when I change the URL to /admin/property/approve/5 (or some other number), it calls the Approve action, but otherwise it always calls the Index action. I tried and created the actionTest() and called it like /admin/property/test, but is still calls the Index action. Here is my configuration:




'<controller:\w+>/<id:\d+>'=>'<controller>/view',

'<controller:\w+>/<action:\w+>/<id:\w+>'=>'<controller>/<action>',

'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',



I tried using this one too:




'<controller:\w+>/<id:\d+>'=>'<controller>/view',

'<controller:\w+>/<action:\w+>/<id:\w+>'=>'<controller>/<action>',

'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

'admin/<controller:\w+>'=>'admin/<controller>',

'admin/<controller:\w+>/<action:\w+>'=>'admin/<controller>/<action>',

'admin/<controller:\w+>/<action:\w+>/<id:\w+>'=>'admin/<controller>/<action>',



but it’s still not working.

Thanks,

Andrej

Try reversing the order of the three final rules in your second version and then move them before the first three. More specific rules need to appear before more general rules.

That worked for me, thanks! I just moved the admin rules before the first three.