<div dir="auto"><div>Thank you Francis Daly. It works.<br><div class="gmail_extra"><br><div class="gmail_quote">On 15 Sep 2017 5:45 am, "Francis Daly" <<a href="mailto:francis@daoine.org">francis@daoine.org</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Thu, Sep 14, 2017 at 11:54:23PM +0800, tseveendorj wrote:<br>
<br>
Hi there,<br>
<br>
>         location / {<br>
<div class="quoted-text">>                 index index.html;<br>
>                 if ($geoip_country_code != "JP") { return 301<br>
> <a href="https://example.com/en/" rel="noreferrer" target="_blank">https://example.com/en/</a>; }<br>
>         }<br>
<br>
>         location = /en/ {<br>
<br>
</div>Change that to "location /en/ {" or "location ^~ /en/ {".<br>
<div class="quoted-text"><br>
>                 index index.html;<br>
>                 try_files $uri $uri/ =404;<br>
>         }<br>
><br>
> I'm trying to if request from other than JP request go to /en/ if<br>
> not /index.html<br>
<br>
</div>You request /en/, which is processed in the second location. That does<br>
an internal redirect to /en/index.html, which is processed in the first<br>
location and returns a 301 redirect to /en/, so you have a loop.<br>
<br>
Change "location =" to break the loop, so that the request to<br>
/en/index.html is not handled in the first location.<br>
<font color="#888888"><br>
        f<br>
--<br>
Francis Daly        <a href="mailto:francis@daoine.org">francis@daoine.org</a><br>
______________________________<wbr>_________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/<wbr>mailman/listinfo/nginx</a><br>
</font></blockquote></div><br></div></div></div>