Yes, you can use CUrlManager component, but if you just want to call actions aboutUs, aboutMe, aboutThem for routes like http: //something-and-yii/index.php?r=site/about-us then you can rewrite Controller’s missingAction() method: http://www.yiiframework.com/doc/api/CController#missingAction-detail, where you should call run() method to run aboutUs action instead of about-us.
public function missingAction($missingActionId) {
switch($missingActionId) {
default:
case '': {
throw new CHttpException(404,Yii::t('yii','The system is unable to find the requested action "{action}".',
array('{action}'=>$missingActionId==''?$this->defaultAction:$missingActionId)));
break;
}
case 'about-us': {
$this->render('about-us');
break;
}
}
}
this works nice, but, what if i want to do it widely, not only for one controller.
if i use this solution, i should add to every controller missingAction() function, and it’s not so pure …
class MyController extends CController
{
public function missingAction($missingActionId)
{
// Some code, where you transform any $missingActionId string (with hyphen)
// into $action (without hyphen)
if (method_exists($this, 'action'.$action))
{
$this->run($action);
}
else
{
parent::missingAction($missingActionId);
}
}
}
And then use MyController as a parent for all you controllers.