How to configure CNC for LinkPager? Set the rule

[ 'pattern' => 'news/<page:\d+>', 'route' => '/news/index' ], 

In action:

 $pages = new Pagination([ 'route' => 'news/', 'totalCount' => $countQuery->count(), 'pageSize' => self::PAGE_SIZE, 'forcePageParam' => false, 'pageSizeParam' => false, ]); 

Anyway LinkPager generates a link of the form

/ news? page = 2

In this case, the link itself is

/ news / 2

works.

What am I doing wrong?

1 answer 1

Route means by itself "controller / action", but not url. It is by coincidence that the name of the controller and the action of Yii2 changes the link. Try to remove the slash from the route

'route' => 'news/index'

or do so

 [ 'news/index' => 'news/<page:\d+>', ],