Как настроить перезапись для указания на account / index.php - PullRequest
0 голосов
/ 23 декабря 2018

Когда я захожу на http://slim.com:8080/parkingmeter/v1/account/test, мне нужно настроить перезапись nginx так, чтобы она указала на account/index.php или admin/index.php.Как мне это настроить?

  1. Введите http://slim.com:8080/parkingmeter/v1/account/test
  2. nginx указывает на каталог root /usr/local/nginx/html/slim/www;
  3. В каталоге www есть файл account / index.php.
  4. Я настроил nginx для дня как

переписать ^ / parkingmeter / v1 / ([az] +) / (. *) $ / $ 1 / index.php? $ 2;

Содержание index.php выглядит следующим образом

 <?php 

 Use \Psr\Http\Message\ServerRequestInterface as Request;
 Use \Psr\Http\Message\ResponseInterface as Response;

 Require '../../vendor/autoload.php';   //require_once __FILE__."/../../../model/UserModel.class.php";

  $config = [
    'settings' => [
        'displayErrorDetails' => true,
    ]   ];   $app = new \Slim\App($config);

  $app->get('/test', function($request, $response, $args){   Return $response->write("Hello, Slim!");   });


  // $app->get('/hello/{name}', function (Request $request, Response    $response, array $args) {   // $name = $args['name'];   // $response->getBody()->write("Hello, $name");

  // return $response;   // });

  //routing   //require_once dirname(__FILE__)."/../../routes/routes.php";

  $app->run();

После настройки выше, браузер не выводит Hello, Slim!

...