![](/img/trans.png)
[英]How to route request url subfolder paths to specific php pages using nginx and php-fpm
[英]nginx + php-fpm - php works except cannot use $_GET
我正在从前端控制器开始滚动自己的mvc框架,该控制器正在运行-所有请求都通过/index.php,后者正在加载引导文件,例如router.php。
但是,$ _ GET不起作用,所以我的router.php文件不起作用。 我的URL方案将只是/ controller / view,省略了.php,但是由于我无法$ _GET将该URL传递给router.php(以加载正确的控制器和视图),因此我无法更改URL。
我到处搜索了解决方案,并在stackoverflow上找到了类似的帖子,但是建议修复不适用于我: https : //serverfault.com/questions/231578/nginx-php-fpm-where-are-my-get -参数
这是我的nginx.conf:
server {
listen 80;
server_name mvcapp;
#Remove Trailing Slash '/'
rewrite ^/(.*)/$ /$1 permanent;
root /usr/local/var/www/mvcapp/public;
index index.php;
location / {
# Neither of the below 2 lines work
#try_files $uri $uri/ /index.php?$query_string;
try_files $uri $uri/ /index.php?$args;
}
#proxy Non-static requests to nginx
location ~ \.php$ {
# Include the default fastcgi_params file included with Nginx
include /usr/local/etc/nginx/fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
# Pass to upstream PHP-FPM;
fastcgi_pass 127.0.0.1:9000;
}
}
我对php-fpm的了解非常薄弱-所以也许我错过了fastcgi_param?
你怎么看错?
(谢谢)
如果要将URI作为get参数传递,请执行以下操作:
try_files $uri $uri/ /index.php?$request_uri;
您的index.php
就像您使用index.php?/controller/view
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.