nginx +超薄位置块设置

时间:2018-01-09 08:50:15

标签: nginx slim

我现在正尝试使用以下目录和文件为新的api设置新的位置块: ROOTDIR
--api1.php
--api
------ LIB
-------- V1
---------- api2.php

这是我的nginx.conf位置块:

location / {
        #root   html;
        index  index.html index.htm index.php;
        #try_files $uri $uri/ =404;
        try_files $uri $uri/ /api1.php?$args;
    }
    location ~ /api/lib/(\w+)/ {


        include        fastcgi_params;
        try_files $uri $uri/ /api2.php?$args;

        #fastcgi_index  index.php;
        fastcgi_index api2.php;


        #fastcgi_split_path_info ^(.+\.php)(/.+)$;


        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        fastcgi_param SCRIPT_NAME $fastcgi_script_name;

        fastcgi_pass   unix:/run/php/php7.0-fpm.sock;
    }
    location ~ \.php$ {
        include        fastcgi_params;
        #fastcgi_index  index.php;
        #try_files $uri $uri/ /api1.php?$args;
        fastcgi_index api1.php;
        #fastcgi_split_path_info ^(.+\.php)(/.+)$;

        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        fastcgi_param SCRIPT_NAME $fastcgi_script_name;

        fastcgi_pass   unix:/run/php/php7.0-fpm.sock;

    }

api文件包含简洁的框架代码,当我输入localhost/getUser/时,fastcgi_script_name将为rootDir/api1.php,getUser将被传递到api1并显示我的预期。
当我输入localhost/api/lib/v1/getUser/时,fastcgi_script_name将为rootDir/api/lib/v1/getUser,并且不会显示任何内容(404),但当我输入localhost/api/lib/v1/时,fastcgi_script_name将为{rootDir/api/lib/v1/api2.php 1}}

任何想法在这里出了什么问题?

0 个答案:

没有答案