在此服务器上找不到Wordpress JsonAPI - / wp-json /

时间:2014-05-24 07:04:10

标签: json wordpress wordpress-plugin openshift

我正在使用以下插件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>

您可以看到网址找不到任何内容。如果API或wordpress出现问题,是否有任何建议?

感谢您的回复

9 个答案:

答案 0 :(得分:29)

当前版本的REST api适用于未启用相当固定链接的网站,网址

    yoursite.com/?rest_route=/ 

会奏效。

答案 1 :(得分:23)

WordPress JSON API depends on pretty permalinks,确保为网站启用了这些功能。

答案 2 :(得分:4)

在我的情况下,在本地linux计算机上安装/配置apache2后出现此错误。我终于发现错误是由于我使用修复的未启用重写模块引起的,

let isOverlaps = frameInParent.intersects(topView.frame)

并确保我的apache2.conf文件(位于/ etc / apache2文件夹中)的sudo a2enmod rewrite指令'AllowOverride'设置为from,而不是从所有

<Directory>

<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>

然后我重新启动了apache2服务,问题已解决。

答案 3 :(得分:4)

我已经多次遇到这个问题。解决方法是这样的:

登录到您的wordpress网站:example.com/wp-admin

然后单击设置

然后单击永久链接

然后将永久链接设置为“ post-name”

答案 4 :(得分:2)

有时解决方案太疯狂又简单!通过移至Admin -> Settings -> Permalinks进入永久链接设置...然后只需按Save Changes即可,无需执行其他任何操作!这将刷新WordPress的内存。

那是为什么?对于以前的情况,我已经更改了主要网站的URL,所以我也必须刷新永久链接。

答案 5 :(得分:1)

我遇到了同样的问题,并想发布我的解决方案,以防其他人遇到这个答案,而其他答案却不能解决问题,因为这是我发生的事情。

就我而言,我没有一个.htaccess文件,该文件具有Wordpress的默认mod_rewrite规则:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

这为我解决了这个问题。根据{{​​3}}:

  

WordPress使用此文件来操纵Apache如何从以下位置提供文件   它的根目录及其子目录。最值得注意的是,WP   修改此文件,使其能够处理漂亮的永久链接。

答案 6 :(得分:0)

如果您已正确安装插件,请务必刷新重写规则。

这可以通过wp-cli完成:http://wp-cli.org/commands/rewrite/flush/

答案 7 :(得分:0)

我正在本地主机子域中的本地开发环境上运行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>

答案 8 :(得分:0)

面对类似的问题,结果表明未启用Apache的mod_rewrite模块。启用它后效果很好。