Installing WordPress In A Sub-Directory Using nginx

So I had this issue recently, I had a WordPress site on the main domain, and another WordPress install for some member stuff in a subdirectory/folder inside the main install. The main site worked fine, and the admin panel etc. But when you tried to change the Permalinks, everything got a 404 error.

I noticed that all requests were being routed back to the main domain (without the additional folder) so I guessed it was probably something to do with nginx, most likely this:

    location / {
           # This is cool because no php is touched for static content
             try_files $uri $uri/ /index.php?$query_string;

Which broke the rewrites inside the folder and sent everything to the main site, to get it working I had to add a couple more location directives for the sub-directory – now all different kinds of Permalink configs work.

This got the site working just fine:

    location  /subinstall {
         root /home/;
         index index.php index.html index.htm;
         try_files $uri $uri/ @wp;

    location @wp {
      rewrite ^/subinstall(.*) /subinstall/index.php?q=$1;

With /subinstall being the name of the sub-folder with the 2nd WordPress install.




You can subscribe via e-mail to get my posts in your Inbox, or stalk me on numerous other platforms.

Follow my Dayre!

, , , , , , ,

Comments are closed.