Ugly Url's With Pagination

I have following code:

[b]config/main.php

[/b]


...

'urlManager'=>array(

        'urlFormat'=>'path',

        'rules'=>array(

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

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

            '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

        ),

        'showScriptName'=>false,

        'urlSuffix'=>'.html',

),

...

controller/blogNewController.php


public function actionIndex() {


            $criteria=new CDbCriteria(array('order'=>'time DESC'));


            $count=BlogNews::model()->count($criteria);

            $pages=new CPagination($count);


            $pages->pageSize=5;

            $pages->applyLimit($criteria);

            $models=BlogNews::model()->findAll($criteria);


            $this->render('index', array(

                    'models' => $models,

                    'pages' => $pages,

           ));

}

view/blogNews/index.php


...

$this->widget('CLinkPager', array(

   'pages' => $pages,

));

...

When click on 1st page url is

../blogNews/index.html?%2FblogNews%2Findex_html=

should be: ../blogNews/index.html

And on 2nd page url is

../blogNews/index.html?%2FblogNews%2Findex_html=&page=2

should be: ../blogNews/index.html?page=2

What can be the problem and why is adding ‘%2FblogNews%2Findex_html=’ ?

I edited CPagination:


//$params=$this->params===null ? $_GET : $this->params;

$params=$this->params===null ? array() : $this->params; //this line added

All working fine but why var_dump($_GET) are returning


array(1) { ["/blogNews/index"]=> string(0) "" }

? Problem with server?

Hi andrzej1_1,

I couldn’t reproduce the issue.

Some questions:

  1. What is the version of Yii?

  2. Is your BlogNews controller in a module?

  3. What do you have in your .htaccess?

  1. Yii 1.1.13

  2. No there isn’t.


#Gzip

<ifmodule mod_deflate.c>

AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript

</ifmodule>

#End Gzip


<IfModule mod_rewrite.c>

 RewriteEngine On

 RewriteBase /

 RewriteCond %{REQUEST_FILENAME} !-f

 RewriteCond %{REQUEST_FILENAME} !-d

 RewriteRule ^(.*)\?*$ index.php?/$1 [L,QSA]

</IfModule>


RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]

instead of


RewriteRule ^(.*)\?*$ index.php?/$1 [L,QSA]

And also note that the guide suggests a very simple rule:

http://www.yiiframework.com/doc/guide/1.1/en/quickstart.apache-nginx-config#apache