如何配置重写以指向account / index.php

时间:2018-12-23 11:34:58

标签: php nginx slim

当我访问http://slim.com:8080/parkingmeter/v1/account/test时,我需要配置nginx重写以指向account/index.phpadmin/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 /([[a-z] +)/(。*)$ /$1/index.php?$2;

  1. 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!

0 个答案:

没有答案