server {
listen 80;
root /var/www/top/public;
index index.php index.html index.htm;
server_name yourservername.com;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location /nested {
alias /what/ever/path/public;
try_files $uri $uri/ @nested;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
}
location @nested {
rewrite /nested/(.*)$ /nested/index.php?/$1 last;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
}
Thanks a lot: https://serversforhackers.com/c/nginx-php-in-subdirectory