URLs like "/theuser/photos/84297512930/"

Hi all,

I need to create URLs like this one:


where theuser can be any of the users of the website, photos is a controller, view the action and the number is the id of the image?

The same for /theuser/photos/add, /theuser/video/1929391 etc…

How can I accomplish this?

Best regards,


I am just a beginning Yii-user, so bear with me…

Take a look at this:


You could probably do something like this:

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

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

That means that ‘username’ must be passed around.

But take a look at the link and study the URL manager.

you can easy do this by setting all path to your folder. Take a look to this function getBaseUrl . setting first argument to true you will be able to get all path and then just specify your folder location manually

Thank you! That was the solution

I used

‘<userName:\w+>/<_c:(photo)>/<_a:\w+>/<idPhoto:\d+>’ => ‘<_c>/<_a>’,

this way I can use URLs like /luislobo/photo/edit/10 or /luislobo/photo/view/10