location / { if (!-e $request_filename){ rewrite ^(.*)$ /index.php?s=$1 last; break; } } location /api { index index.php index.html index.htm; if (!-e $request_filename) { rewrite ^/api/(.*)$ /api.php?s=$1; } }