Yii问题中的静态页面

时间:2010-12-22 06:32:11

标签: yii

'urlManager'=>array(
    'urlFormat'=>'path',
    'rules'=>array(
        '<view>' => array('site/page/view/'),
        '<controller:\w+>/<id:\d+>'=>'<controller>/view',
        '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
        '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
        //'index' => array('site/index'),
    ),
),

我目前在main.php文件中有这个。

我遇到的问题是,当我查看/index.php/index时,我已经在pages文件夹中显示了索引页面但是当我到达/index.php/about时,我仍然在页面中获得了index.php文件文件夹中。

2 个答案:

答案 0 :(得分:2)

'urlManager'=>array(
    'urlFormat'=>'path',
    'rules'=>array(
        '<controller:\w+>/<id:\d+>'=>'<controller>/view',
        '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
        '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
        //'index' => array('site/index'),
        '<view>' => array('site/page/view/'),
    ),
),

应该是这样的:

答案 1 :(得分:1)

现在规则应该是(至少在版本1.1.12中)

'<view:\w+>' => 'site/page', 

此代码将向SiteController :: actionPage提供$ _GET ['view'],例如http://example.com/test会设置$ _GET ['view'] ='test'

相关问题