F
F
fman22015-11-03 21:24:29
Yii
fman2, 2015-11-03 21:24:29

How to process such a rule in Yii2?

Good day. I've been struggling with this problem for over an hour now.
The essence of the problem is this:
there are links like
sitename.ru/post-o-chem-to1
sitename.ru/post-o-chem-to2/blabla/1
sitename.ru/post-o-chem-to3/blablabla/2
and there is a link like
sitename.ru/forum
How to write a rule so that first there is a check if forum/ is passed and if not. everything would go to another controller.
I think the actions are performed sequentially and wrote this code, but it does not work, the last action is performed:

'urlManager'=>[
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' =>  [
                '/forum/'       =>  'forum/', // это правило пропускается, ссылка вида sitename.ru/forum/ игнорируется
                '/<url:[a-zA-Z/0-0-]+>' => 'sitetopic/index' // это правило все перехватывает
            ]
        ]

Thanks for the help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
.
. ., 2015-11-05
@somenugget

Try to write like this
'forum/<action:\w+>' => 'forum/<action>',

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question