在一个配置文件YII中定义页面URL

时间:2015-07-12 06:46:00

标签: php url yii yii-url-manager

无论如何都要在一个配置文件中定义页面URL,并使其更加用户友好。 例如

/index.php/randomuser/default/index => randomuser
/index.php/randomuser/default/view => randomuserview
/index.php/useroftheday/default/index => useroftheday
/index.php/useroftheday/default/view => userofthedayview

1 个答案:

答案 0 :(得分:0)

只需在配置文件中配置 Url Manager ,就像这样 -

'urlManager'=>array(
    'urlFormat'=>'path',
    'showScriptName'=>false,
    'rules'=>array(
        'randomuser'=> 'randomuser/default/index',
        'randomuserview'=> 'randomuser/default/view',
        'useroftheday'=> 'useroftheday/default/index',
        'userofthedayview'=> 'useroftheday/default/view'
    )
)

您的新网址将是 - http://domain.com/randomuser