Prefix for all controlelr when user is authorized

Hello,

I am wondering if it is possible to make prefix to all controller using urlManager when user is logged in.

For example,

right now I have different contollers used ONLY by authorzed users:




domain.com/settings/view

domain.com/order/view



etc

I would like to make them in the following way:




domain.com/client/settings/view

domain.com/client/order/view



But additiona of "client" in the front of every controller should ONLY happen, when user is authorized. For example, SiteController should be ignored, because it contains actions for login, signup, etc.

Any suggestions?

The Yii advanced application template gives you everything you need. I would use it if you are not too far along in your development…it will save you a lot of time.

I am using advanced version, but thx.

Any ideas? Guys?

Not sure if this is a good solution, but this is what I did and it seems to work well.

In urlManager I specified prefix for Controller that is used by guests and then for any other controlers I add prefix such as "client".

Meaning that some tweaking of rules made it work correctly.

Have not idea why I did not think about it earlier and why nobody suggested it as well <_<

Use the URL manager!

In a project of mine, I pass ‘identifier’ as a parameter to my actions:


'/projects/<identifier>/<action>' => 'project/<action>',



That rule gives me URLs like "/projects/first/view", etc.

You can simply pass the client to your actions and let the URL manager create the URLs for you.

yeah, I’ve made it this way already, but thanks for help. For some reason I made it overcomplicated at the beginning :D