Yii 配置默认controller和action

设置默认controller

  在/protected/config/main.php添加配置

1 <?php
2 return array(
3     'name'=>'Auto',
4     'defaultController'=>'auto',
5     ...

  上述配置了默认的controller为AutoController.php

设置默认action

  在AutoController.php中设置

class AutoController extends CController
{
    public $defaultAction = 'test';

    public function actionTest()
    {
        ...
    }
    ...

  此时访问xxxx/index.php会默认转到xxxx/index.php?r=auto/test

原文地址:https://www.cnblogs.com/zhaobolu/p/3640543.html