Welcome! Log In Create A New Profile

Advanced

Index fallback?

Edho Arief
October 09, 2016 11:58PM
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?

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Index fallback?

Edho Arief October 09, 2016 11:58PM

Re: Index fallback?

Edho Arief October 10, 2016 02:10AM

Re: Index fallback?

Edho Arief October 10, 2016 02:20AM

Re: Index fallback?

Nurahmadie Nurahmadie October 10, 2016 02:30AM

Re: Index fallback?

Edho Arief October 10, 2016 02:42AM

Re: Index fallback?

Nurahmadie Nurahmadie October 10, 2016 02:52AM

Re: Index fallback?

Edho Arief October 10, 2016 02:56AM

Re: Index fallback?

Francis Daly October 10, 2016 02:24AM

Re: Index fallback?

Edho Arief October 10, 2016 02:28AM

Re: Index fallback?

Edho Arief October 16, 2016 04:12AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 283
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready