【问题标题】:File not found for php files找不到 php 文件的文件
【发布时间】:2019-09-11 07:23:04
【问题描述】:

我在 nginx 反向代理后面运行 wordpress。

Home 等工作正常,但是当用户转到以 .php 结尾的 url 时,我收到 404 File not found. 错误。

这里是相关的nginx配置:

        location /en/us/ {
                proxy_pass https://10.0.10.11/en/us/;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header Host $host;
        }

【问题讨论】:

  • “相关”是什么意思?此配置文件中是否还有其他 location 块?
  • 对于这条路径,没有没有。 wordpress home 在 /en/us/ 下工作正常

标签: php wordpress nginx reverse-proxy nginx-location


【解决方案1】:

看起来有另一个规则覆盖所有 php 文件并返回 404。如果您使用的是 bitnami nginx,请编辑以下文件;

sudo vim /opt/bitnami/nginx/conf/bitnami/bitnami.conf

并注释掉

#include "/opt/bitnami/nginx/conf/bitnami/phpfastcgi.conf";

这是

location ~ "\.php$" {
    fastcgi_index index.php;
    if (!-f $realpath_root$fastcgi_script_name) {
        return 404;
    }

    include /etc/nginx/conf/phpfastcgiparam.conf;
    fastcgi_pass unix:/run/php7/php-fpm.sock;
}

【讨论】:

    猜你喜欢
    • 2016-06-30
    • 2014-05-31
    • 2015-12-15
    • 2017-09-05
    • 1970-01-01
    • 2013-08-10
    • 1970-01-01
    • 1970-01-01
    • 2014-08-04
    相关资源
    最近更新 更多