小编Rob*_*obL的帖子

如何在nginx上的子目录中获取Slim PHP Framework路由

我正在尝试将Slim应用程序移动到子目录中,以便可以访问它example.com/api/,但是我遇到了严重的问题,导致路由工作.

主脚本是/website/workbench/api/public/index.php,所以调用example.com/api/project/1应该打到API文件夹.但是,我还需要能够访问example.com的index.html文件(在Angular JS上运行).

当我去时它确实击中了PHP脚本example.com/api/project/1- 我可以var_dump变量并看到它们.但是,路由没有生效,请求变量似乎是空的.

在/ etc/nginx的/网站可用/工作台

server {
    listen   80; ## listen for ipv4; this line is default and implied

    root /website/workbench;
    index index.php index.html index.htm;

    server_name example.com;

    location / {
        try_files $uri $uri/ index.php?$query_string;
    }

    location /api/ {
        try_files $uri $uri/ /api/public/index.php?$query_string;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param PHP_VALUE …
Run Code Online (Sandbox Code Playgroud)

php nginx slim

3
推荐指数
2
解决办法
4721
查看次数

标签 统计

nginx ×1

php ×1

slim ×1