Remove URI string?

daveyfx nginx-forum at nginx.us
Thu Jan 10 23:25:39 UTC 2013


Francis Daly Wrote:
-------------------------------------------------------
> On Thu, Jan 10, 2013 at 11:37:44AM +0700, Edho Arief wrote:
> > On Thu, Jan 10, 2013 at 11:35 AM, daveyfx <nginx-forum at nginx.us>
> wrote:
> 
> Hi there,
> 
> > > I gave it a try and it did not work out.  My access log repeated
> the
> > > following entry ~ 20 times.
> 
> As mentioned:
> 
>   curl -i http://server/something
>   curl -i http://server/
> 
> are much friendlier for testing with. You'll see exactly what the
> server
> sends back.
> 
> > location = / {
> >   index index.html;
> > }
> > location / {
> >   return 302 /;
> > }
> 
> With that configuration, a request for / will lead to an internal
> rewrite to /index.html, which will then hit the second location and do
> an external redirect again.
> 
> So either add a third "location = /index.html" to handle that, or
> avoid
> the internal rewrite by doing something like
> 
>   try_files /index.html =404
> 
> in the "location = /" block.
> 
> 	f

To all -

Thank you for your help with this.  Francis put the puzzle together and the
following is working out great for me.

server {
    server_name
    host1.domain.com
    host2.domain.com
    ...
    ... (so on and so forth)

    root /path/to/document/root;

    location = / {
        try_files /index.html = 404;
    }

    location / {
        return 302 /;
    }
}

> -- 
> Francis Daly        francis at daoine.org

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,234822,234914#msg-234914



More information about the nginx mailing list