Ngnix 404 Slim 4.x

Hello, I started using the 4.x version today, but there was a problem after the installation. I think it is a problem with ngnix’s url rules. My rules are as follows:

location ~ ^/json-api {
alias /www/wwwroot/xxx.com/json-api;
try_files $uri $uri/ /index.php$is_args$args;
location ~ .php$ {
 include fastcgi.conf;
 fastcgi_index index.php;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 fastcgi_intercept_errors on;         
 fastcgi_pass 127.0.0.1:9000;

}
}

The program code is as follows:
<?php
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;

require DIR . ‘/vendor/autoload.php’;

/**

  • Instantiate App
  • In order for the factory to work you need to ensure you have installed
  • a supported PSR-7 implementation of your choice e.g.: Slim PSR-7 and a supported
  • ServerRequest creator (included with Slim PSR-7)
    */
    $app = AppFactory::create();

// Add Routing Middleware
$app->addRoutingMiddleware();

/*

  • Add Error Handling Middleware

  • @param bool $displayErrorDetails -> Should be set to false in production

  • @param bool $logErrors -> Parameter is passed to the default ErrorHandler

  • @param bool $logErrorDetails -> Display error details in error log

  • which can be replaced by a callable of your choice.

  • Note: This middleware should be added last. It will not handle any exceptions/errors

  • for middleware added after it.
    */
    $errorMiddleware = $app->addErrorMiddleware(true, true, true);

// Define app routes
$app->get(’/’, function (Request $request, Response $response, $args) {
$response->getBody()->write(“Hello world!”);
return $response;
});

// Run app
$app->run();