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)

About Ricard Torres

Senior Front-end Software Engineer at Netcentric, from Barcelona, Haidong Gumdo Instructor (korean martial art of the sword), street photographer, travel lover, TV addict, Boston Red Sox fan, and privacy advocate.

@ricard_dev @ricard_dev

📝 Blog 🎙 Podcast

Leave a Reply

Add <code> Some Code </code> if you need to.

*
*