I have the following config:
server {
listen 80;
server_name localhost;
location /app {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /app/index.html?$args;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
When navigating to http://localhost:8000/app/ all works as expected but when removing the trailing slash (http://localhost:8000/app) nginx returns 301 status response and I am being redirected to http://localhost/app.
How can I make nginx work with both http://localhost:8000/app/ and http://localhost:8000/app (with and without trailing slash).
nginxto do when a URI without a trailing/points to a directory? At the moment$uri/tells it to issue a3xxresponse, and thelistendirective tells it to use port 80 in the redirect.$uri/in thetry_filesstatement. You could just remove it.try_files $uri /app/index.html?$args;? can you post it as an answer - for it to be excepted