出于某种原因“开箱即用”,Wordpress JSON API无法在Nginx上运行。我在nginx conf中尝试了几种重定向方案。我唯一能做的就是?json
。但是,这不适用于身份验证和注册。
作为一个FYI,我正在开发一个cordova应用程序,并尝试将WP JSON API用于WP后端。
答案 0 :(得分:8)
我的Nginx conf为wp-json API。
location / {
# http://v2.wp-api.org/guide/problems/#query-parameters-are-ignored
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ ^/wp-json/ {
# if permalinks not enabled
rewrite ^/wp-json/(.*?)$ /?rest_route=/$1 last;
}
答案 1 :(得分:5)
I found the solution to the problem. Make sure that permalinks are working properly before you assume (like I did) that it is an issue with the plugin.
I was able to correct permalinks for a wordpress site in a subdirectory on an nginx site. This article will help you if you face the same issue here
答案 2 :(得分:0)
我的案例是将wordpress部署在网站根目录下的子目录中,这是使其工作的步骤
/www/wwwroot/www.abc.com/public/
-通过www.abc.com
访问/www/wwwroot/www.abc.com/public/blog/
-通过www.abc.com/blog/
访问blog
chmod -R www:www blog
-在您的Web根目录中运行此命令。location /blog/ {
index index.php;
try_files $uri $uri/ /blog/index.php?$args;
}