Yii under Nginx

Hey :)

I'm running the latest stable Nginx and trying to get rewrites working for Yii.  I've read the related cookbook article but no CSS is being used, and only the home page shows up.  Any other page access results in a 404 error.

Here's what I've done…

In protected/config/main.php I have the following related to UrlManager:

                'urlManager'=>array(


                            'urlFormat'=>'path',


                            'showScriptName'=>false,


In the nginx.conf file, I have these rewrite rules in place, per the cookbook:



        # The location is /


        # Rewrite all other URLs


            if (!-e $request_filename) {


            #rewrite ^/(.+)$ /index.php?url=$1 last; // This is the CakePHP rule that works


            rewrite (.*) /index.php/$1;


            break;


            }


I've also added the fcgi_param PATH_INFO $fastcgi_script_name directive to the fastcgi config in nginx.conf.

It's probably fairly simple but no matter what I try, I get 404 errors after the home page and there's no CSS.

Thanks for any help!

Does this help? http://www.yiiframew…oc/cookbook/15/

No sir, that’s what I’m currently using ;)

So it looks like the cookbook method does work, but I have to define rewrite rules for each controller.  Is that right?

Also, when messing around with the 'First Yii App' in the definitive guide, logging in redirects me back to the home page (as a logged in user) but shows index.php in the address bar even with showScriptName=>false.

Isn't there a way to have the rewrite rule for the entire app, and how can I hide the script name on redirect?

Thanks!

Here is the Nginx location block I ended up using for controllers:



        location ~ /(site|users) {   // looks like I have to list all controllers here?


            # Rewrite all other URLs


            if (!-e $request_filename) {


            rewrite ^/(.+)$ /index.php?url=$1 last;


            break;


            }


Also, in the testdrive app SiteController's actionLogin, if I change Yii::app()->user->returnUrl to Yii::app()->user->homeUrl, the index.php part of the URI doesn't show up.

I hate to call this a bug because, at this point, what do I know…but is that intended?