Assuming having a virtual site called api
$ sudo vi /etc/nginx/conf.d/api.conf
point root to the web folder
server { listen 80; listen [::]:80; server_name www.yoursite.com; root /usr/share/nginx/html/api/web; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log error; #site root is redirected to the app boot script location = / { try_files $uri @rewriteapp; } location @rewriteapp { # rewrite all to app.php rewrite ^(.*)$ /app.php/$1 last; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location /50x.html { root /usr/share/nginx/html/api/web; } # Deny all . files location ~ /\. { deny all; } location ~ ^/(app|app_dev|config)\.php(/|$) { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } }
Let’s test it
YEEYYYY!!!!