Linkpager Pagination Not Working When Pretty Urls Enabled

In my config I have enabled urlManager:




'urlManager' => [

            'enablePrettyUrl' => true,

            'showScriptName' => false,

        ],  



On my site/index (home) page I’m displayed a list of model objects witt a pagination widget:

I works OK with pretty url’s disabled, but with enablePrettyUrl=true (as in config above), the paginator’s links

are broken:

The url that the paginator points to for page 2 is:

{mysite}/site/index?page=2

But getting a Not Found error on this page.

(Removing the ‘site/index’ part of the url above and loading it in the browswer works OK - but how to make the paginator point to the correct url?)

thanks much for help!

Gvanto

you have to have a htaccess in place




RewriteEngine On


RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f


RewriteRule . index.php

create a new .htaccess file under web/ folder with above code if you don’t have one in place

edit:


'urlManager' => [

            'enablePrettyUrl' => true,

            'showScriptName' => false, // this has been deprecated in favor of enablePrettyUrl you don't need this anymore

        ],

Hi alirz,

OK added .htaccess - still doesn’t work.

btw: yii2-guide documentation has showScriptName in there.

thanks for the help,

G

Ok found it! Fix was fairly simple, map home page (’’) to site/index:




'urlManager' => [

            'enablePrettyUrl' => true,

            'showScriptName' => false,

            

            'rules' => [

                '' => 'site/index', 

            ],

        ], 



Go the sharks!! I’m from Richards Bay :)

nice good to know, there are few people from SA on this forum

don’t map it to empty string change it to


'rules' => [

                '/' => 'site/index', 

            ],