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


defining Page URLs in one configuration file YII

无论如何都可以在一个配置文件中定义页面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

只需在Url管理器配置文件中像这样配置-

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

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