How To Remove Cntroller Name From Url

Hi everyone.

In yii framework how i can remove or hide the module’s controller name from url.

I have url like this


I would like to be that url like this



You could use Urlmanager

with rule

'admin/login' => 'admin/default/login/'

for example in protected/config/main.php file in bellow block add the specified rule








                'admin/login' => 'admin/default/login'





You can use the controllerMap in config/main.php.

'controllerMap' => array(

        'admin' => 'admin.controllers.DefaultController', 

                   //or 'application.modules.admin.controllers.DefaultController'

        'user' => '' 



But if you call ‘admin/login’ (or another action of the DefaultController) the module of the DefaultController will not be loaded / initialized.

You have to change the constructor of the DefaultController like this:

class DefaultController extends CController {


     * Have to assign the module in __construct

     * if loaded directly from controllerMap


     * @param string $id

     * @param string $module


    public function __construct($id, $module = null)


        if (!isset($module))

              $module = Yii::app()->getModule('admin');

        parent::__construct($id, $module);