FAQ Suggestions

Ivo Welch ivo.welch at gmail.com
Mon Feb 20 01:51:39 UTC 2023


please ignore previous email.  nanaya has an explanation that I need
to explore.  I think this would make a great example for an FAQ...

On Sat, Feb 18, 2023 at 10:27 PM nanaya <me at nanaya.net> wrote:
>
> Hi
>
> On Sun, Feb 19, 2023, at 10:27, Ivo Welch wrote:
> > 2. why does
> >
> > ```
> > location /wth {
> >    root /var/www/fcgi-bin/;
> >    index wth-root.html;
> >  }
> > ```
> >
> > not resolve '/wth' (but incidentally does resolve '/wth-root.html',
> > though not '/wth-root').
> >
>
> it's one of the common confusions. Just /wth doesn't trigger index listing as it doesn't end with a forward slash. /wth-root does match because /wth matches anything that starts with /wth (some people seem to think it matches /wth/ directory but it really doesn't - it's just prefix matching after all).
>
> If you have /var/www/fcgi-bin/wtha.html file and try accessing /wtha.html, it'll return that file, for example. Same with /wth-root.html as you experienced.
>
> Back to /wth, it'll try to return file /var/www/fcgi-bin/wth (which probably doesn't exist).
>
> If what you actually want is to to match /wth/, it needs to be `location /wth/`. Although then it can't be accessed through /wth as it doesn't match anymore (unless it exists as directory in other location like `location /`). In which case I usually add `location = /wth { return 302 /wth/; }` to fix this one special case.
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> https://mailman.nginx.org/mailman/listinfo/nginx


More information about the nginx mailing list