Yii urlManager规则

时间:2018-10-18 07:23:11

标签: yii pretty-urls

要更改几个网址,我必须在config main.php中写些什么:
1.从'page?role = 4'到'new'
2.从“ site / page / 85”到“ anothernew”

以下规则在urlManager中不起作用,它们返回一个带有标题但无内容的页面:
 1.'new'=>'page?role = 4'
 2.'anothernew'=>'site / page / 85'

我也尝试使用完整网址,但没有运气:
 1.'new'=>'https://www.sitename.com/page?role=4'
 2.'anothernew'=>'https://www.sitename.com/site/page/85'

已将其添加到config.php:

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

0 个答案:

没有答案