WordPress in sub-directory with NGINX

If you want to have a WordPress installation inside a sub-folder. Maybe you have a WordPress inside a WordPress, sounds more complicated that what it actually is.

You might get an error when trying to publish a post or page:

The response is not a valid JSON response.

The scenario could be like this:

  • Example.com ( it's a WordPress installation )
  • Example.com/other-site ( also a WordPress installation )

Here the NGINX snippet to make it work

location / {
    index index.php index.html index.htm;
    try_files $uri $uri/ /index.php?$args;
#    try_files $uri $uri/ =404;

location /subsite {
    try_files $uri $uri/  /subsite/index.php?q=$uri&$args;

location /othersite {
    try_files $uri $uri/  /othersite/index.php?q=$uri&$args;
}Code language: PHP (php)

Leave a Reply

Your email address will not be published. Required fields are marked *