当前位置:首页 > PHP教程 > PHP常见问题

yii框架配置默认controller和action示例

设置默认controller

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

复制代码 代码如下:

<?php
return array(
 'name'=>'auto',
'defaultcontroller'=>'auto',

上述配置了默认的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



【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!