0
votes

we need to serve the static content through nginx. below is our location directive:

location ~ /app$ {
        root   /srv/deployments/app/build/;
        index  index.html;
    }

now we are expecting any thing like /app/login,/app/signup will be served by this location directive. but when we try to access /app/login we 404 error. and in addition to above location directive if we define below location directive, then it work.

location ~ /app/login$ {
        root   /srv/deployments/app/build/;
        index  index.html;
}

as there can be multiple routes, how can we define a location directive with regex so that any which match /app/.* should served by single location.

1

1 Answers

0
votes

Please check if this link helps.

It suggests (specific to that question)

location ~ ^/sitename/[0-9a-z]+/index.php$ {
    fastcgi_pass phpcgi;
}

where:

^ -> Start of string

[0-9a-z]+ -> matches all the characters in this range

index.php$ -> end of string with index.php