How should I configure NGINX for multi-language in a subfolder?

Hey everyone. First-time poster, working on my third Kirby site. I’ve successfully built and deployed two sites; both were on NGINX servers. One was in a sub-folder. This is the first one that requires multi-lang, and I can’t figure out how to configure NGINX to route properly.

Here’s my NGINX config to route a single-language site properly within the sub-folder “kirbytest”:

# Kirby  nginx configuration
    location /kirbytest/content {
            rewrite ^/kirbytest/content/(.*)\.(txt|md|mdown)$ /kirbytest/index.php;
    }
    location /kirbytest/site {
            rewrite ^/kirbytest/site/(.*) /kirbytest/index.php;
    }
    location ~ ^/assets/(.*) {
            return 301 /kirbytest/assets/$1;
    }
    location /kirbytest/ {
            rewrite ^/kirbytest/(kirby|panel\/app|panel\/tests)/(.*) /kirbytest/index.php;
            if (!-e $request_filename){
                    rewrite ^/kirbytest/panel/(.*) /kirbytest/panel/index.php;
            }
            if (!-e $request_filename){
                    rewrite ^/kirbytest/(.*) /kirbytest/index.php;
            }
    }

If I configure the default language to sit at the root / , this will still load the Home page. However, none of my other pages can be accessed, for any language. If I set the default English to /en , and Japanese to /jp , I can’t access any pages at all.

What am I missing to enable Kirby to route properly to /en and /jp folders? Can NGINX & Kirby even do this?

Now, on my local test server, I’m just running Apache at the server root, and I can access every page on /en and /jp. It’s only when deploying to my remote server, where the site unfortunately needs to live entirely inside a sub-folder, that the routing breaks.

Is it possible to do what I’m trying to do? The only server I can use to deploy is NGINX; and again, that’s worked fine with single-language in the past. I might eventually be able to deploy to a URL root, but maybe not. I’d like to get it working as-is. Ultimately I could run everything on an Apache server; but I’d rather not have to go through that!

Thank you to anyone who can offer any advice.

I tested on another root domain, and these NGINX settings do work just fine for /en and /jp multi-language routing, if everything is in the domain root. So… what’s missing from the sub-folder setup, I wonder?

Have you found out what cuased this? I do have the very same problem, but with Kirby 4.3.

In Kirby 3 and 4, there’s nothing special you need to do for multi-language sites.

Based on our nginx cookbook recipe, use a location block like this to match the subfolder:

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

(assuming your document root points to the root of the domain)