我正在尝试将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
变量并看到它们.但是,路由没有生效,请求变量似乎是空的.
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)