【问题标题】:CakePHP app 404s when going to URL subdirectories转到 URL 子目录时,CakePHP 应用程序 404
【发布时间】:2018-08-05 21:39:32
【问题描述】:

我最近将一个 CakePHP 项目导入了一个新服务器,并且能够加载 webroot,例如example.com 但是,当我转到 example.com/pages/about 或 example.com/pages/contact 时,我得到一个 404。我正在使用 Nginx,我认为它没有正确配置,因为相同的 CakePHP 项目部署在不同的服务器。 (我对 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;
        }

}

我想知道是什么未正确配置导致任何非根 uris 为 404。

【问题讨论】:

标签: php nginx cakephp debian


【解决方案1】:

根据对我的问题的评论,更改

try_files $uri $uri/ =404;

...到...

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

...成功了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-02-23
    • 1970-01-01
    • 1970-01-01
    • 2011-05-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-06
    相关资源
    最近更新 更多