<?php
class SiteController extends CController
{
...
public function actionIndex()
{
if (!Yii::app()->user->IsGuest){ //jika diakses oleh selain guest
//render view server/index
$this->render('index');
}else{ //kalau tidak
//redirect ke index.php?r=login/index
$this->redirect(array('login/index'));
}
}
...
}
Kalau controller dikaitkan dengan model yang mengandung CRUD, kita dapat menyesuaikan behaviour accessRules()-nya.