【发布时间】:2017-06-15 04:22:44
【问题描述】:
我在尝试从 Fuelphp 框架中的控制器执行操作时遇到了这个问题,我从 nginx 收到 404 消息。我能够看到,例如localhost/index.php 或只是 localhost,但是当我尝试访问 localhost/index.php/login/huehue 之类的操作控制器时,我收到 404 错误。谁能帮我?这个应用程序目前在 apache 中运行,我在这里也遇到了这个问题,但是当我执行时一切都很好
a2enmod 重写
然后我尝试搜索 nginx 的等效配置,发现如下:
位置 /{ try_files $uri $uri/ /index.php?$args /index.php?q=$request_uri }
或者这个:
位置/{
重写 ^ /index.php?/$request_uri;}
但他们没有为我工作。我花了几个小时试图找出原因。这是我网站的实际 vhost 文件配置:
server {
listen 80;
listen [::]:80;
root /var/www/nginx/goutmeet;
index index.php index.html index.htm index.nginx-debian.html;
server_name goutmeet.local www.goutmeet.local;
location / {
try_files $uri $uri/ /index.php?$args /index.php?q=$request_uri @handler;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location @handler {
rewrite ^ /index.php?/$request_uri;
}
}
我很想知道如何解决这个问题,因为有时使用 nginx 是比 apache 更好的选择,而在使用 fuelphp 框架时遇到这个问题并且不能同时使用这两个很棒的工具是很糟糕的。 提前致谢。
【问题讨论】:
标签: php nginx web frameworks fuelphp