Changing route in a ListView

Hi, I would like to know if it is possible to change the routes of a pager from a ListView (for SEO reasons).

For example I’ve got this ListView object :

<?= ListView::widget([
    'dataProvider' => $dataProvider,
    'itemView' => '_item',
    'itemOptions' => ['tag' => false],
]) ?>

The routes generated for these pages are like that :

The problem is that this route is really not good for our SEO because on our old site the route looked like this :

If someone knows if it is possible to change the routes of a list view please help me.
If it is not, I will just make my own pager.

Thank you in advance.

Hi @TitoDev,

This sounds like a url manager issue, not pager.

    '<controller:\w+>/page/<page:\d+>' => '<controller>',

It doesn’t work, let’s take a closer look.

Here is my current ListView:

The pager generated looks like that :

But I am looking for this :

For now my url manager is the following :
and the routes files contains all the routes of my app, like this one :

The $dataProvider comes from ForumController/actionIndex.

I have already tried multiple methods like modifying the route in the pagination but it does not affect the routes at all :

Let me know if I understood something wrong and thank you for the answer.

This line looks OK to me, but you also have to check other lines above it, since there’s always a possibility that other rule might be applied to the pattern before it gets applied.

I don’t think it’s necessary.

BTW, would you please use text instead of image for showing your code?

1 Like