Hello,
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 : monsite.com/project/gmsService/index.php/Api/Plant for list all data in "Plant" Table
Instead of that, I have to use : monsite.com/project/gmsService/index.php/Api/list?model=Plant.
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 :
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'rules'=>array(
'post/<id:\d+>/<title:.*?>'=>'post/view',
'posts/<tag:.*?>'=>'post/index',
// 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
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
have you any idea where is problem, because I really don’t understand