A
A
AlexAll2019-02-20 08:43:31
Yii
AlexAll, 2019-02-20 08:43:31

How to create cnc links for yii2?

I have a url manager set up, but the links are not CNC like this site.ku/category/view?slug=pervaya
This is how I create this link

<?= Html::a('Первая категория', Yii::$app->UrlManager->createUrl(['/category/view' , 'slug' => $model->slug]); ?>

Here are the settings
'urlManager' => [
    'class' => 'yii\web\UrlManager',
    'enablePrettyUrl' => true,
    'showScriptName' => false,
    'baseUrl' => '',
    'rules' => [
        '' => 'site/index',
        //'<action>'=>'site/<action>',
        'contact' => '/contact/index',
        'about' => '/about/index',
        '<_c:[\w\-]+>' => '<_c>/index',
        '<_c:[\w\-]+>/<id:\d+>' => '<_c>/view',
        '<_c:[\w\-]+>/<_a:[\w-]+>' => '<_c>/<_a>',
        '<_c:[\w\-]+>/<id:\d+>/<_a:[\w\-]+>' => '<_c>/<_a>',
    ],
];

How to do? so that the link is not of this type site.ku/category/view?slug=pervaya but of this site.ku/category/pervaya

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
padlyuck, 2019-02-20
@padlyuck

https://www.yiiframework.com/doc/guide/2.0/en/runt...
'<_c:[\w\-]+>/<slug:[\w\-]+>' => '<_c>/view',

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question