我如何重定向到另一个入口脚本


How can I redirect to another entry script?

应用程序中有两个输入脚本,如下所示。如何设置路由将/example.com/admin重定向到example.com/backend.php

谢谢。

查看有关URL管理的文档:

  • http://www.yiiframework.com/doc/guide/1.1/en/topics.url

在不知道设置细节的情况下,在protected/config/main.php(如果main.php是您的应用程序配置文件)中,您将需要以下内容:

// note: this is extracted from a project which uses 'friedly urls',
//       depending on your setup, YMMV
'urlManager'=>array(
    'urlFormat'=>'path',
    'showScriptName' => false,
    'rules'=>array(
        '<controller:'w+>/<id:'d+>'=>'<controller>/view',
        '/admin'=>'/backend',    // <-- define your custom routes/redirects here
    ),
),