Wordpress JsonAPI - 在此服务器上找不到 /wp-json/
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23842235/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Wordpress JsonAPI - /wp-json/ was not found on this server
提问by Anna.Klee
I am using the following plugin Json Rest API.
我正在使用以下插件Json Rest API。
To test the plugin the documentationstates that I should just use:
要测试插件,文档指出我应该只使用:
$ 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>
As you can see nothing is found by the URL. Any recommendations if there is a problem with the API or wordpress?
如您所见,该 URL 未找到任何内容。如果 API 或 wordpress 有问题,有什么建议吗?
I appreciate your reply
我很感激你的回复
回答by Anoop D
The current version of REST api for sites with pretty permalinks not enabled, the url
未启用漂亮永久链接的站点的 REST api 的当前版本,url
yoursite.com/?rest_route=/
will work .
将工作 。
回答by Eric Andrew Lewis
The WordPress JSON API depends on pretty permalinks, make sure you have them enabled for the site.
WordPress JSON API依赖于漂亮的永久链接,请确保您为站点启用了它们。
回答by Aurovrata
In my case, I got this error after installing/configuring apache2 on my local linux machine. I finally found the error to be cause by the rewrite module not being enabled which I fixed using,
就我而言,在本地 linux 机器上安装/配置 apache2 后出现此错误。我终于发现错误是由我修复的重写模块未启用引起的,
sudo a2enmod rewrite
sudo a2enmod rewrite
as well as ensuring that my apache2.conf file (located in the folder /etc/apache2) has its<Directory>directive 'AllowOverride' set to all rather than none, from
以及确保我的 apache2.conf 文件(位于文件夹 /etc/apache2 中)将其<Directory>指令“AllowOverride”设置为 all 而不是 none,从
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
to
到
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
then I restarted apache2 service and the problem was resolved.
然后我重新启动了 apache2 服务,问题解决了。
回答by Daggie Blanqx - Douglas Mwangi
I have faced this issue several times . The solution is this :
我已经多次遇到过这个问题。解决方案是这样的:
Login into your Wordpress site: example.com/wp-admin
登录您的 Wordpress 站点:example.com/wp-admin
Then click on settings
Then click on permalinks
Then set permalinks to "post-name"
Save Changes
然后点击设置
然后点击永久链接
然后将永久链接设置为“ post-name”
保存更改
回答by Mohammad AlBanna
Sometimes the solution is crazy and easy! Go to the permalink settings by moving to Admin -> Settings -> Permalinks...then just hit Save Changeswithout doing anything else! This refreshes the memory of WordPress.
有时解决方案既疯狂又简单!通过移动到永久链接设置Admin -> Settings -> Permalinks...然后直接点击Save Changes而不做任何其他事情!这刷新了WordPress的记忆。
Why is that? For a situation I had before, I had changed the main website URL so I had to refresh the permalinks as well.
这是为什么?对于我之前遇到的情况,我更改了主网站 URL,因此我也必须刷新永久链接。
回答by JMac
I was running WP on a local dev environment in a subdomain of localhost (eg mysite.localhost:8888)
我在 localhost 的子域(例如 mysite.localhost:8888)中的本地开发环境中运行 WP
The solution for me was to update the virtual host config in httpd-vhosts.conf to set directory options, similarly to Aurovrata's answer:
我的解决方案是更新 httpd-vhosts.conf 中的虚拟主机配置以设置目录选项,类似于 Auroprata 的回答:
<VirtualHost *:8888>
ServerName mysite.localhost
DocumentRoot "/Users/myusername/mysite"
<Directory /Users/myusername/mysite>
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
回答by logos_164
I had this same issue and wanted to post my solution in case anyone else comes across this answer and the other answers don't solve the issue, as this happened with me.
我有同样的问题,想发布我的解决方案,以防其他人遇到这个答案,而其他答案没有解决问题,因为这发生在我身上。
In my case I didn't have a .htaccessfile with Wordpress' default mod_rewriterules:
就我而言,我没有.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>
This solved the issue for me. Per the documentation:
这为我解决了这个问题。根据文档:
WordPress uses this file to manipulate how Apache serves files from its root directory, and subdirectories thereof. Most notably, WP modifies this file to be able to handle pretty permalinks.
WordPress 使用此文件来操纵 Apache 如何从其根目录及其子目录提供文件。最值得注意的是,WP 修改了这个文件以能够处理漂亮的永久链接。
回答by Austin Pray
If you have correctly installed the plugin, be sure to flush the rewrite rules.
如果您已正确安装插件,请务必刷新重写规则。
This can be accomplished with the wp-cli: http://wp-cli.org/commands/rewrite/flush/
这可以通过 wp-cli 完成:http: //wp-cli.org/commands/rewrite/flush/


