我使用以下插件Json Rest API。
为了测试插件,documentation声明我应该使用:
$ curl -i http://testpress-maxximus.rhcloud.com/wp-json/
HTTP/1.1 404 Not Found
Date: Sat, 24 May 2014 07:01:21 GMT
Server: Apache/2.2.15 (Red Hat)
Content-Length: 303
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /wp-json/ was not found on this server.</p>
<hr>
<address>Apache/2.2.15 (Red Hat) Server at testpress-maxximus.rhcloud.com Port 8
0</address>
</body></html>
正如您所看到的,URL没有找到任何内容。如果API或wordpress出现问题,是否有任何建议?
感谢您的回复
当前版本的REST api适用于未启用相当固定链接的网站,即网址
yoursite.com/?rest_route=/
将工作 。
WordPress JSON API depends on pretty permalinks,确保为网站启用了它们。
在我的情况下,我在本地linux机器上安装/配置apache2后出现此错误。我终于发现错误是由于我没有启用重写模块,我修复了使用,
sudo a2enmod rewrite
以及确保我的apache2.conf文件(位于文件夹/ etc / apache2中)将its<Directory>
指令'AllowOverride'设置为all而不是none,来自
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
至
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
然后我重新启动了apache2服务,问题解决了。
我曾多次遇到过这个问题。解决方案是这样的:
登录您的wordpress网站:example.com/wp-admin
然后单击设置
然后单击永久链接
然后设置永久链接为“post-name”
如果您已正确安装插件,请务必刷新重写规则。
这可以通过wp-cli:http://wp-cli.org/commands/rewrite/flush/完成
我在localhost的子域中的本地开发环境中运行WP(例如mysite.localhost:8888)
对我来说,解决方案是更新httpd-vhosts.conf中的虚拟主机配置以设置目录选项,类似于Aurovrata的答案:
<VirtualHost *:8888>
ServerName mysite.localhost
DocumentRoot "/Users/myusername/mysite"
<Directory /Users/myusername/mysite>
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
有时解决方案是疯狂和容易的!转到Admin -> Settings -> Permalinks
转到永久链接设置...然后只需点击Save Changes
而不做任何其他事情!这刷新了WordPress的记忆。
这是为什么?对于我以前的情况,我已经更改了主网站的URL,所以我也必须刷新永久链接。