Friendly Url Pagination

Using pagination, my url looks like this:


user/list?user%2Flist=&User_page=2

I´d like my url to be like:


user/page=2

I know I can do it with "urlManager" and "rules" but I don´t know which expression I must use.

Any help please?

Thanks.

Any suggestion?

Thanks in advance.

Try something like this:


'user/page-<User_page:\d+>' => 'user/list',

More info about the UrlManager and how to use it:

http://www.yiiframework.com/doc/guide/1.1/en/topics.url

Would it be


'user/page=<User_page:\d+>' => 'user/list',

? (The difference is just the equal sign :) )

I quote from RFC 3986 (page 11 con.)

[QUOTE]2.2. Reserved Characters

URIs include components and subcomponents that are delimited by

characters in the "reserved" set. These characters are called

"reserved" because they may (or may not) be defined as delimiters by

the generic syntax, by each scheme-specific syntax, or by the

implementation-specific syntax of a URI’s dereferencing algorithm.

If data for a URI component would conflict with a reserved

character’s purpose as a delimiter, then the conflicting data must be

percent-encoded before the URI is formed.

  reserved    = gen-delims / sub-delims





  gen-delims  = &quot;:&quot; / &quot;/&quot; / &quot;?&quot; / &quot;#&quot; / &quot;[&quot; / &quot;]&quot; / &quot;@&quot;





  sub-delims  = &quot;&#33;&quot; / &quot;&#036;&quot; / &quot;&amp;&quot; / &quot;'&quot; / &quot;(&quot; / &quot;)&quot;


              / &quot;*&quot; / &quot;+&quot; / &quot;,&quot; / &quot;;&quot; / &quot;=&quot;

[/QUOTE]

It basicly states that the "=" sign in a URI is reserved as a delimiter sign. Therefore I recommend you not to use it as a non-delimiting sign within your URI (especially because the HTTP scheme is using it as delimiter for parameter keys and its values)

Thanks for your suggestions, but it doesn´t work for me. I must be doing something really wrong, because it seems to append the last url whenever I request a new page on my list.

In my config file, in the urlManager I have:


'user/pag/<User_page:\d>' => 'user/list',

For my first page the url is:


myWeb/user/list

For my second page the url is:


myWeb/user/pag/2?user%2Flist=

For my third page the url is:


myWeb/user/pag/3?user%2Fpag%2F2=&user%2Flist=

For my fourth page the url is:


myWeb/user/pag/4?user%2Fpag%2F3=&user%2Fpag%2F2=&user%2Flist=

Habe a look at http://www.yiiframework.com/doc/api/1.1/CPagination#pageVar-detail. You should either change this variable to "User_page" or you nee d to adjust sour URL rule-

Thanks to your post I have found this other link. At the end, somebody said his problem was with the .htaccess file.

I checked mine and I changed this line:


RewriteRule ^(.+)$ index.php?$1 [PT,L,QSA]

for this other one:


RewriteRule . index.php

And my pagination started to work :) . Thanks for your help to everyone.

Howewer, I don´t understand the difference between the two lines changed. Will I have any other problem with this new line in my .htaccess? I´m not pretty good with .htaccess rewrite sintax.