Welcome! Log In Create A New Profile

Advanced

Re: Too many redirects

September 14, 2017 06:08PM
Thank you Francis Daly. It works.

On 15 Sep 2017 5:45 am, "Francis Daly" <francis@daoine.org> wrote:

On Thu, Sep 14, 2017 at 11:54:23PM +0800, tseveendorj wrote:

Hi there,

> location / {
> index index.html;
> if ($geoip_country_code != "JP") { return 301
> https://example.com/en/; }
> }

> location = /en/ {

Change that to "location /en/ {" or "location ^~ /en/ {".

> index index.html;
> try_files $uri $uri/ =404;
> }
>
> I'm trying to if request from other than JP request go to /en/ if
> not /index.html

You request /en/, which is processed in the second location. That does
an internal redirect to /en/index.html, which is processed in the first
location and returns a 301 redirect to /en/, so you have a loop.

Change "location =" to break the loop, so that the request to
/en/index.html is not handled in the first location.

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Too many redirects

Eberx September 14, 2017 11:56AM

Re: Too many redirects

Francis Daly September 14, 2017 05:46PM

Re: Too many redirects

Eberx September 14, 2017 06:08PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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