#StackBounty: #wordpress #wordpress-rest-api #nginx-config How do I configure nginx for WordPress REST API in sub-folder?

Bounty: 200

I am trying to set up multiple WordPress sites in sub-folders under our domain (ie not multi-site), but I have difficulty configuring the REST API endpoints. For example, this endpoint works fine:


But this endpoint gives a 404:


I have tried to rewrite the failing url to the working url with these rules in my nginx configuration:

location /site1/wp-json {
    rewrite ^/site1/wp-json(.*)$ /site1/?rest_route=$1;

location /site1/ {
   try_files $uri $uri/ /site1/index.php$is_args$args;

I can’t see any special handling of wp-json in the WordPress docs or the nginx wiki. What am I missing here? The permalinks for the site is set to Numeric (https://example.com/site1/archives/123) if that might play a role.

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.