gvanto
(Gvanto)
September 29, 2014, 5:33am
1
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
alirz23
(Alirz23)
September 29, 2014, 9:55am
2
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
],
gvanto
(Gvanto)
September 30, 2014, 12:07am
3
Hi alirz,
OK added .htaccess - still doesn’t work.
btw: yii2-guide documentation has showScriptName in there.
thanks for the help,
G
gvanto
(Gvanto)
September 30, 2014, 12:19am
4
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
alirz23
(Alirz23)
September 30, 2014, 6:03am
5
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',
],