从yii中的URL中删除一些单词


remove some word from URL in yii

目前我的网站中有一些URL看起来像:

.com/page/about-company
.com/page/approval-license
.com/page/recruitment-areas

为此,我在配置中编写了规则,如:

'rules' => array(
            'page/<slug:[a-zA-Z0-9-_'/]+>/' => 'page/view',
        ),

但我想从这些URL中删除单词页面。我想要类似的URL:

.com/about-company
.com/approval-license
.com/recruitment-areas

我能做什么?请引导。

你可以试试这个:

'rules' => array(
        '<slug:[a-zA-Z0-9-_'/]+>' => 'page/view',
    ),

'rules' => array(
        '<slug>' => 'page/view',
    ),

这样,如果你的url像example.com/some-text,那么PageController中的view操作就会被执行。