nginx+wordpress api出现404

譬如wordpress主页:https://xxx.com/

api网址为https://xxx.com/wp-json/

假如访问出现404,则可以尝试访问https://xxx.com/index.php?rest_route=/wp-json/ ,如果显示正常,表名api功能已经开启。

那么此时是nginx路由配置出问题,打开/etc/nginx/nginx.conf,

在server里面添加下面代码即可:

location ~^/wp-json/ {

rewrite /wp-json/(.*?)$ /?rest_route=/$1 last;

}

发表评论

电子邮件地址不会被公开。 必填项已用*标注