Yii Framework Forum: Yii under Nginx - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii under Nginx Rate Topic: -----

#1 User is offline   drech 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 100
  • Joined: 06-April 09

Posted 06 April 2009 - 02:10 PM

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!



0

#2 User is online   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,896
  • Joined: 04-October 08
  • Location:DC, USA

Posted 06 April 2009 - 02:27 PM

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

#3 User is offline   drech 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 100
  • Joined: 06-April 09

Posted 06 April 2009 - 02:30 PM

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

#4 User is offline   drech 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 100
  • Joined: 06-April 09

Posted 06 April 2009 - 09:24 PM

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!
0

#5 User is offline   drech 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 100
  • Joined: 06-April 09

Posted 07 April 2009 - 12:20 AM

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?

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users