Woocommerce REST API-Nginx-错误404未找到 [英] Woocommerce REST API - Nginx - Error 404 Not Found

查看:521
本文介绍了Woocommerce REST API-Nginx-错误404未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的VPS( debian 9,Nginx )上使用 Woocommerce (v 3.5.4) Rest Api .

I'm trying to use the Woocommerce (v 3.5.4) Rest Api on my VPS (debian 9, Nginx).

在我的本地计算机( Windows 10,XAMPP )中,一切正常.

Everything works well in my local machine (windows 10, XAMPP).

wpbop/是存储wordpress文件的文件夹(var/www/wpbop/).

wpbop/ is the folder (var/www/wpbop/) where the wordpress files are stored.

浏览器中的下一个基本URL应该发送API的终结点(第一步无需进行身份验证): http:// my-public-ip /wpbop/wp-json/wc/v3

The next basic URL in a browser should send the endpoints of the API (no need of athentication for this first step) : http://my-public-ip/wpbop/wp-json/wc/v3

或者在命令行中卷曲

卷曲 http://127.0.0.1/wpbop/wp-json /wc/v3

curl http://127.0.0.1/wpbop/wp-json/wc/v3

在两种情况下,我都收到错误404 Not Found.

in both cases, i get error 404 Not Found.

我可以顺利访问博客/管理博客( http:// my-public-ip /wpbop )

I can acces to the blog / admin blog without any problems ( http://my-public-ip/wpbop )

我的永久链接设置在wordpress管理面板中的邮政名称"上,很多人在相同情况下都要求这样做.

My permalinks are set on "Postname" in wordpress admin panel, this is recommanded by many people in same case.

由于我的Wordpress安装位于子域中,

Since my Wordpress installation is in a sub-domain,

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

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

找不到index.php.只需通过以下方式更改此行:

try_files $ uri $ uri//wpbop/index.php$is_args$args;

try_files $uri $uri/ /wpbop/index.php$is_args$args;

问题可能出在我的Nginx conf文件中吗?

Perhaps problem is coming from my Nginx conf file ?

server {
  server_name localhost;
  listen 80;
  root /var/www;

    location /wpbop {

        index index.php;

        access_log /var/log/nginx/blog.access.log;
        error_log /var/log/nginx/blog.error.log;

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

            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';

        location ~ \.php$ {
            try_files $uri =404;
            fastcgi_index index.php;
            fastcgi_pass 127.0.0.1:7000;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include /etc/nginx/fastcgi_params;
        }
    }
}

我尝试了很多事情,没有任何结果,但是我被困了几天.有人能帮我吗 ? 感谢您的阅读.

I tried many things without any results, and I'm stuck for several days. Can someone help me ? Thanks for reading me.

推荐答案

这种情况需要在NGINX配置文件中进行简单修复.这与我的wordpress安装路径有关.

This case need a simple fix in the NGINX configuration file. This is related to the path of my wordpress installation.

由于我的Wordpress安装位于子域中,

Since my Wordpress installation is in a sub-domain,

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

->找不到index.php.只需通过以下方式更改此行:

--> can't find index.php. Just change this line by :

try_files $uri $uri/ /wpbop/index.php$is_args$args;

这篇关于Woocommerce REST API-Nginx-错误404未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆