Url problems

Hi so I am new to using Yii but not PHP in general.

I am having a problem on getting the URL’s to structure correctly. Using the blog demo included when downloading the framework I want to have the URL for the frontpage posts like this hxxp://domain.com/post/page/2










That does not work and returns saying can’t find action “page”. If I make it


It works until after the first page is clicked then eventually leading to a url like


I am wondering how I can get the url to show as I want it to.

Server is set correctly as other pages work without a problem.

Request URI and Query string parsed to server

["QUERY_STRING"]=>string(20) "r=/post/index/page/2"

["REQUEST_URI"]=>string(18) "/post/index/page/2"

I disabled the AJAX load on the CListView widget with ‘ajaxUpdate’=>false no other changes were made.

I think this is just a simple thing but I can’t find any help in http://www.yiiframework.com/doc/guide/1.1/en/topics.url to fix the problem.

Any help would be great.



Hi there Matt,

I think your problem relies in that ‘page’ is not an action but a parameter. If you do:


you tell Yii that post controller - action index is post controller - action page and than after is a parameter integer that will be named Post_page…

I believe that if you put:

post/<page:\d+> => post/index

will be ok

Ok after some crazy debugging I got it to work!! Seems it had to do with nginx rather than Yii at least I think.


I used that rule and links to other page numbers show and work as they should.


From this page it says to put in

location /yiiGuestbook {

    try_files $uri $uri/ /yiiGuestbook/index.php?r=$request_uri;


for .7 and higher (I am running .8.5) I had (running in root directory)

location / {

    try_files $uri $uri/ /index.php?r=$request_uri;


However changing it to

location / {

     try_files $uri $uri/ /index.php;


Appears to have made it work correctly without problems. Now it seems to be working I will do some more testing and post a comment on that wiki entry for others.

Happy Coding!


Original post before finding solution----

Thanks for the reply but I didn’t have much luck in getting it working :(


Creates the page links as /post/index?Post_page=2 which don’t work when clicked.

Error is "The system is unable to find the requested action "index?Post_page=2"."



Links are created as expected /post/2 (Although I would prefer /post/page/2 or /post/page2) however when clicking onto the page results in the error "The system is unable to find the requested action "2"."

Is there anyone with some other ideas?

Any help would be great



I have seen I made a mistake, Post_page was the variable… is index or view the action you want that variable to be passed?

Index was the action. Just from the front page of the blog demo where all posts are shown and page numbers.


Very weird… after reading the post I truly don’t understand why it doesnt work for you. I have something similar to you but I use (more general):

<_c>/<_a>/<for:\d+>/<group:\d+>/*’ => ‘<_c>/<_a>’,

Could you please try your URL in the following format instead?

‘<post>/<page>/<Post_page:\d+>’=>‘post/index’, <— this the first one






I do have it working now though (After changing nginx’ config) with


However with nginx set as

try_files $uri $uri/ /index.php;

Rather than

try_files $uri $uri/ /index.php?r=$request_uri;

Just means I can’t use ?foo=bar so I have to set this


to make sure Yii makes the rest of the urls in nice format without the _GET parameters (in the url).

By the way are you using nginx? or apache/something else?



I do use Apache in all my developments…

If anyone ran into this problem, an another way to make Yii working under nginx is replacing try_files line with the following snippet:

if (!-e $request_filename) {

    rewrite (.*) /index.php last;