newbie: can we change mvc links?

Hello everyone,

I’m a newbie to PHP, let alone Yii, so please bare with me.

As far as I know, the path determined by the MVC model goes something like domain/model/action/controller, something like domain/user/info/12345

Can we do something like domain/controller/model/action instead?

I want to have the link look like domain/username/gallery/add, is that possible or easy?

Thanks

actually by default it is domain/controller/action

So in domain/user/info/12345, ‘user’ is the controller name, ‘info’ is the action within that controller. models are not within the url. However, a lot of people have controllers that correspond to a certain models, and thus have the name excluding the controller’s suffix. You can write special rules allowing any type of URL structure you like:

http://www.yiiframework.com/doc/guide/topics.url

or mod_rewrite it up!

you can define paths in config.php for example


$frontend=$protected.DIRECTORY_SEPARATOR.'scope'.DIRECTORY_SEPARATOR.'frontend';

Yii::setPathOfAlias('frontend', $frontend);


return array(

    'basePath'=>$frontend,

    'controllerPath' => $frontend.'/controllers',

    'viewPath' => $frontend.'/views',

...........

Just a note that if you’re using modules then the structure will change to domain/module/controller/action. As said above you can specify basic rewrite rules in the config under the urlManager/rules bit.