1 個回答
- 最新
- 最多得票
- 最多評論
1
Hello.
Try running the command below.
If the permalink setting is "Basic", accessing "wp-json/wp/v2/" seems to result in 404 Not Found.
If the permalink setting is "Basic", please use the following URL to execute the Rest API.
https://stackoverflow.com/questions/34670533/wordpress-rest-api-wp-api-404-error-cannot-access-the-wordpress-rest-api
curl -X GET https://pinoyagri.com/index.php?rest_route=/wp/v2/users
相關內容
- AWS 官方已更新 8 個月前
- AWS 官方已更新 3 年前
- AWS 官方已更新 1 年前
- AWS 官方已更新 7 個月前
Thank you providing me a good insight to resolve this issue. This request "curl -X GET https://pinoyagri.com/index.php?rest_route=/wp/v2/users" works. However when I run this "curl -X GET https://pinoyagri.com/wp-json/wp/v2/types/post?context=edit", it returned "404 Not Found". I just don't know the cause of this issue. I searched in the internet but most solutions are for Apache and my environment was set up in Nginx. This is the platform of my environment: PHP 8.2 running on 64bit Amazon Linux 2023/4.0.1. In my observation, there are endpoints that are not properly configured on my environment. Any help is appreciated.
You need to use the URL below as mentioned in my answer. Your WordPress permalink settings are probably set to "Basic". In that case, access the API from the URL below.
If I set the permalink setting to "Post Name", can I use it?
Perhaps the contents of this post may also be useful. https://wordpress.stackexchange.com/questions/253734/wp-json-return-404-but-wp-json-wp-v2-works-fine-on-my-nginx-server
Yes and I'm using "Post Name" for my Permalinks. When I run "curl -X GET https://pinoyagri.com/index.php?rest_route=/wp/v2/types/post?context=edit", I got this output "{"code":"rest_no_route","message":"No route was found matching the URL and request method.","data":{"status":404}}". I really appreciate sharing me the post relevant to my issue. Meanwhile, do you think adding the following code to .ebextensions is good? "files: "/etc/nginx/conf.d/my_custom_config.conf": mode: "000644" owner: root group: root content: | location /wp-json { rewrite ^/wp-json(.*)$ /index.php?rest_route=$1 last; }"
The URL I shared seems to be successful with the following Nginx settings added. I see no problem with adding your settings. Try the following settings as well.