Index fallback?

Nurahmadie Nurahmadie nurahmadie at gmail.com
Mon Oct 10 06:50:15 UTC 2016


Hi,

On Mon, Oct 10, 2016 at 1:39 PM, Edho Arief <me at myconan.net> wrote:

> Hi,
>
> On Mon, Oct 10, 2016, at 15:29, Nurahmadie Nurahmadie wrote:
> > Hi
> >
> > > On Mon, Oct 10, 2016, at 15:08, Edho Arief wrote:
> > > > Hi,
> > > >
> > > > On Mon, Oct 10, 2016, at 12:56, Edho Arief wrote:
> > > > > 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
> > > > >
> >
> > Still need more locations, but independent to directories you want to
> > access:
> >
> >
> >     server {
> >             listen 7770;
> >             root /tmp;
> >             autoindex on;
> >             autoindex_format json;
> >     }
> >
> >     server {
> >             listen       80;
> >             server_name  localhost;
> >             index index.html;
> >             root /tmp;
> >
> >             location ~ /.*?[^/]$ {
> >                     try_files $uri @redir;
> >             }
> >
> >             location @redir {
> >                     return 301 $uri/;
> >             }
> >
> >             location ~ /$ {
> >                     try_files $uri"index.html" @reproxy;
> >             }
> >
> >             location @reproxy {
> >                     proxy_pass http://localhost:7770;
> >             }
> >     }
> >
>
> Thanks, but that's even longer than my ifs. Also one `server { }` and
> one regexp location too many.
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>

Ah, sorry I thought it's obvious that the other server is just served as
dummy example,
also I have this tendency to avoid `if` as much as possible, so yeah

-- 
regards,
Nurahmadie
--
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20161010/1007e591/attachment.html>


More information about the nginx mailing list