September 13, 2010 04:26AM
On Mon, Sep 13, 2010 at 03:46:55PM +1000, Splitice wrote:

> Location / would also work although server is probably better

No. If you request "/dir/" with the confuguration

location / {
rewrite ^(.*/)index.html http://$host$1 permanent;
index index.html;
}

then nginx will do an internal redirect to "/dir/index.html".
If the redirect will be handled in the "location /", then
nginx will rewrite it to an external redirect "http://host/dir/".
And so on.

In this configuration:

rewrite ^(.*/)index.html http://$host$1 permanent;

location / {
index index.html;
}

nginx will not run the server level rewrite, after the internal redrect,
so there will not be the loop.

> Sent from my iPod
>
> On 13/09/2010, at 4:09 AM, Igor Sysoev <igor@sysoev.ru> wrote:
>
> > On Sun, Sep 12, 2010 at 12:13:11PM -0400, ez77 wrote:
> >
> >>> rewrite ^(.*/)index.html http://$host$1 permanent;
> >>
> >> Hi Mat,
> >>
> >> I like your proposal better, which looks more elegant without the if
> >> clause, but I don't know where to include it. Under location / I
> >> get a
> >> redirect loop.
> >
> > You should set it on server level.
> >
> >
> > --
> > Igor Sysoev
> > http://sysoev.ru/en/
> >
> > _______________________________________________
> > nginx mailing list
> > nginx@nginx.org
> > http://nginx.org/mailman/listinfo/nginx
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://nginx.org/mailman/listinfo/nginx

--
Igor Sysoev
http://sysoev.ru/en/

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

Beginner's question: redirecting /dir/index.html to /dir/

ez77 September 09, 2010 06:22PM

Re: Beginner's question: redirecting /dir/index.html to /dir/

mat h September 09, 2010 09:52PM

Re: Beginner's question: redirecting /dir/index.html to /dir/

Igor Sysoev September 10, 2010 12:02AM

Re: Beginner's question: redirecting /dir/index.html to /dir/

Igor Sysoev September 10, 2010 12:14AM

Re: Beginner's question: redirecting /dir/index.html to /dir/

ez77 September 10, 2010 12:51PM

Re: Beginner's question: redirecting /dir/index.html to /dir/

Igor Sysoev September 10, 2010 03:58PM

Re: Beginner's question: redirecting /dir/index.html to /dir/

ez77 September 11, 2010 05:25PM

Re: Beginner's question: redirecting /dir/index.html to /dir/

ez77 September 11, 2010 09:39PM

Re: Beginner's question: redirecting /dir/index.html to /dir/

mat h September 11, 2010 09:48PM

Re: Beginner's question: redirecting /dir/index.html to /dir/

ez77 September 12, 2010 12:13PM

Re: Beginner's question: redirecting /dir/index.html to /dir/

Igor Sysoev September 12, 2010 02:14PM

Re: Beginner's question: redirecting /dir/index.html to /dir/

Splitice September 13, 2010 01:52AM

Re: Beginner's question: redirecting /dir/index.html to /dir/

ez77 September 13, 2010 03:07AM

Re: Beginner's question: redirecting /dir/index.html to /dir/

mat h September 13, 2010 03:26AM

Re: Beginner's question: redirecting /dir/index.html to /dir/

Igor Sysoev September 13, 2010 04:26AM

Re: Beginner's question: redirecting /dir/index.html to /dir/

ez77 September 13, 2010 01:39PM

Re: Beginner's question: redirecting /dir/index.html to /dir/

Eugaia September 13, 2010 01:44PM

Re: Beginner's question: redirecting /dir/index.html to /dir/

Igor Sysoev September 13, 2010 02:52PM

Re: Beginner's question: redirecting /dir/index.html to /dir/

ez77 September 13, 2010 06:51PM

Re: Beginner's question: redirecting /dir/index.html to /dir/

ez77 September 13, 2010 06:59PM

Re: Beginner's question: redirecting /dir/index.html to /dir/

ez77 September 13, 2010 07:27PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 220
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