Wordpress REST API (wp-api) 404 错误:无法访问 WordPress REST API [英] Wordpress REST API (wp-api) 404 Error: Cannot access the WordPress REST API

查看:90
本文介绍了Wordpress REST API (wp-api) 404 错误:无法访问 WordPress REST API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 XAMPP 进行本地开发时,我已经使用 Wordpress REST 插件 WP-API 几个月了.我最近将我的网站迁移到 EC2 实例,一切正常除了我现在每次尝试访问 API 上的任何端点时都会收到带有以下消息的 404:

<块引用>

在此服务器上找不到请求的 URL/wordpress/wp-json/

使用以下结构启用了漂亮的永久链接 http://.../wordpress/sample-post/ 在导航到特定帖子时工作正常浏览器.

以下是有关我的设置的一些详细信息:

  • WordPress 4.4.1
    • 不是多站点
  • WP REST API 插件 2.0-beta9
  • Apache 2.2.22
  • Ubuntu 12.04.5

任何帮助将不胜感激,因为我已经浏览了 SO 和 WP 支持论坛几个小时并且我没有想法.谢谢!

解决方案

UPDATED NEW WAY

我在本地项目中也遇到过类似的问题.我在我的项目 url 之后使用了 index.php 并且它起作用了.

http://localhost/myproject/index.php/wp-json/wp/v2/posts

如果显示 404 错误,则首先更新永久链接(请参阅分页导航不起作用"部分

如果有效,也许您需要在 ubuntu 上启用 mod_rewrite:

a2enmod 重写须藤服务 apache2 重启

安装

<块引用>

REST API 包含在 WordPress 4.7 中!不再需要插件,只需安装最新版本的 WordPress 即可.

如果您在 4.7 之前:

  1. 从这里下载插件:http://v2.wp-api.org/

  2. 安装并激活它.

用法

获取所有帖子:

www.mysite.com/wp-json/wp/v2/posts

对于搜索功能,搜索测试帖子如下所示:

/wp-json/wp/v2/posts?filter[s]=test

I have been using the Wordpress REST plugin WP-API for months now while developing locally with XAMPP. I recently migrated my site to an EC2 instance and everything is working fine except I now get a 404 with the following message whenever I try to access any endpoint on the API:

The requested URL /wordpress/wp-json/ was not found on this server

Pretty permalinks are enabled with the following structure http://.../wordpress/sample-post/ which works fine when navigating to a specific post in the browser.

Here are some details about my setup:

  • Wordpress 4.4.1
    • Not a Multisite
  • WP REST API plugin 2.0-beta9
  • Apache 2.2.22
  • Ubuntu 12.04.5

Any help would be greatly appreciated as I have gone through SO and the WP Support forums for several hours and am out of ideas. Thank you!

解决方案

UPDATED NEW WAY

I also faced similar problem in a local project. I used index.php after my project url and it worked.

http://localhost/myproject/index.php/wp-json/wp/v2/posts

If it displays a 404 error then update permalinks first (see "Paged Navigation Doesn't Work" section

If it works, maybe you need to enable mod_rewrite, on ubuntu:

a2enmod rewrite
sudo service apache2 restart

Installation

The REST API is included in WordPress 4.7! Plugins are no longer required, just install the latest version of WordPress and you're ready to go.

If you're before 4.7:

  1. Download plugin from here: http://v2.wp-api.org/

  2. install and activate it.

Usage

To get all posts:

www.mysite.com/wp-json/wp/v2/posts

For the search functionality, searching for test post looks like this:

/wp-json/wp/v2/posts?filter[s]=test

这篇关于Wordpress REST API (wp-api) 404 错误:无法访问 WordPress REST API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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