Answer the question
In order to leave comments, you need to log in
CNC not working on Yii2?
Hi all! In my project on Yii2, I implemented user-friendly (NC) links, as described in the article here . In the database I write alias: 'test-alias.html', and in the route I write 'site/about' and everything works with a bang. But if you write a route like 'category/2' in the database, the CNC link is not formed (it just goes to mysite.com/ru/category/2).
My link is formed like this:
and in the UrlManager there is a rule:
How to make it so that when you click on a link like "category / 2", the link is formed and opened by the CNC? Url::to(['category/view', 'id' => $hit->id])
'category/<id:\d+>' => 'category/view',
Answer the question
In order to leave comments, you need to log in
in UrlManager
link like this
Url::to(['category/view', 'alias' => $hit->alias]); //так
Yii::$app->urlManager->createUrl(['category/view', 'alias' => $hit->alias]); //или так
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question