A
A
akula222016-03-15 22:22:50
Yii
akula22, 2016-03-15 22:22:50

Yii2 rules in Url manager, how to specify all characters?

I form a link like this ['/user/default/view', 'username' => $model->username]
in Url manager such a rule
'user/<username:[\w_-]+>' => 'user/default/view',
If the name is simple, for example test, then I get the correct link /user/test
and if vova-pupkin or id123123123 then the link is /user/default/view?username=vova-pupkin
How to make a rule?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander N++, 2016-03-16
@sanchezzzhak

:[\w\d\-]+

D
Dmitry Voronkov, 2016-03-16
@DmitryVoronkov

try like this.
'user/<username:[-\w]+>' => 'user/default/view',

A
akula22, 2016-03-16
@akula22

The issue was resolved, I had some kind of conflict in the code

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question