Index fallback?
Edho Arief
me at myconan.net
Mon Oct 10 03:56:57 UTC 2016
I somehow can't make this scenario work:
root structure:
/a/index.html
/b/ <-- no index.html
accessing:
1. site.com/a -> redirect to site.com/a/ -> show /a/index.html
2. site.com/b -> redirect to site.com/b/ -> show @fallback
Using
try_files $uri $uri/index.html @fallback;
doesn't work quite well because #1 becomes this instead:
1. site.com/a -> show /a/index.html
and breaks relative path javascript/css files (because it's `/a` in
browser, not `/a/`).
And using
try_files $uri @fallback;
Just always show @fallback for both scenarios.
Whereas
try_files $uri $uri/ @fallback;
Always return 403 for #2 because the directory exists and there's no
index.
As a side note,
error_page 404 = @fallback;
Wouldn't work because as mentioned in the previous one, it returns 403
for #2 (directory exists, no index), not 404.
Is there any way to do it without specifying separate location for each
of them?
More information about the nginx
mailing list