简体   繁体   English

转到URL子目录时的CakePHP应用404s

[英]CakePHP app 404s when going to URL subdirectories

I recently imported a CakePHP project to a new server and am able to load the webroot eg example.com however when I go to example.com/pages/about or example.com/pages/contact I get a 404. I'm using Nginx, which I assume isn't configured correctly because the same CakePHP project is deployed on a different server. 我最近将CakePHP项目导入到新服务器中,并且能够加载webroot(例如example.com),但是当我转到example.com/pages/about或example.com/pages/contact时,我得到了404。我认为Nginx的配置不正确,因为同一CakePHP项目已部署在不同的服务器上。 (I don't have a great understanding about CakePHP but have used similar PHP MVC frameworks eg Laravel) (我对CakePHP不太了解,但是使用了类似的PHP MVC框架,例如Laravel)

 server { listen 80 default_server; listen [::]:80 default_server; root /home/me/directory/webroot; autoindex off; index index.php; server_name _; location / { try_files $uri $uri/ =404; } location ~ \\.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; } } 

I'm wondering what isn't configured correctly that causes any non-root-uris to 404. 我想知道什么配置不正确导致404错误。

Per the comment to my question, changing 根据对我的问题的评论,更改

try_files $uri $uri/ =404;

...to... ...至...

try_files $uri $uri/ /index.php?$args;

...did the trick. ...成功了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM