Issue With Yii Rest API and nginx URL


I have used this tutoriel for build a REST Api with Yii.

I used nginx, and the url manager don’t work properly

According, the tutoriel and UrlManager configuration, I should use url like : for list all data in "Plant" Table

Instead of that, I have to use :

This is my nginx.conf :

worker_processes 8;

user www-data www-data;

events {

  worker_connections 1024;


http {

  client_max_body_size 20G; 

  include mime.types;

  default_type application/octet-stream;

  sendfile on;

  keepalive_timeout 65;

  gzip on;

  gzip_min_length 0;

  gzip_http_version 1.0;

  gzip_types text/plain text/xml application/xml application/json text/css application/x-javascript text/javascript application/javascript;


  server {

    listen 80;

    server_name localhost;

    set $yii_bootstrap "index.php";

    charset utf-8;




   location /project {

     root /var/www/;

     index  index.html $yii_bootstrap;

     try_files $uri $uri/ /$yii_bootstrap?$args;

     rewrite ^/project/gmsService/index.php(.*)$ /project/gmsService/index.php?r=$1 last;

     #rewrite ^/api/index.php/(.*)$ /api/index.php?url=$1 last;




And this is my UrlManager config :







			// REST patterns

			array('api/list', 'pattern'=>'api/<model:\w+>', 'verb'=>'GET'),

			array('api/view', 'pattern'=>'api/<model:\w+>/<id:\d+>', 'verb'=>'GET'),

			array('api/update', 'pattern'=>'api/<model:\w+>/<id:\d+>', 'verb'=>'PUT'),

			array('api/delete', 'pattern'=>'api/<model:\w+>/<id:\d+>', 'verb'=>'DELETE'),

			array('api/create', 'pattern'=>'api/<model:\w+>', 'verb'=>'POST'),

			// Other controllers




have you any idea where is problem, because I really don’t understand

you should add one more rules like this

array('api', 'pattern'=>'api/<model:\w+>', 'verb'=>'GET'),

you should actionIndex method in your apicontroller

inside controller you can get GET[‘model’] name like this…

I hope it will solve your problem :)