0

I am using Nginx two serve two static websites (react).

http://example.com should serve site A and http://example.com/b should serve site B.

This is my Nginx Configuration

server {
    listen 80;
    listen [::]:80;

    server_name example.com;

    location / {
        alias /var/www/html/site_a/;
        try_files $uri /index.html;
    }

    location /b {
        alias /var/www/html/site_b/;
        try_files $uri $uri/ /index.html;
    }
}

If request url is http://example.com/ then site_a/index.html is returned.

If request url is http://example.com/b/ then site_b/index.html is returned.

If request url is http://example.com/b/abc then site_a/index.html is returned.

What changes are needed so that http://example.com/b/* always returns site_b/index.html?

1 Answers1

0

I have found solution Nginx location configuration (subfolders).

Looks like alias and try_files don't work as expected.