我想在我的php脚本中解析URL,因此,我需要从特定位置到路由到index.php的所有内容。
但是,当我直接导航到特定的php文件时,只能看到该文件。
示例,请求;
所有路线都应到达io_lib:format
当前配置:
api/index.php
答案 0 :(得分:1)
是,因为它按预期指向/index.php
而不是/api/index.php
。只需将try_files更改为try_files /api/index.php?$args =404;
。并在专用的/api/index.php
位置将请求转发到php-fpm。
$query_string
变量,只有$args
变量可以传递所有参数。仅当变量$request_uri
正确编码后才可以使用。您的php脚本应使用explode('?', $_SERVER['REQUEST_URI'], 2)[0]
处理正确的请求。