nginx rewrite or internal redirection cycle

Solution 1:

The culprit is: try_files $uri $uri/ ;

http://nginx.org/r/try_files (note that the last parameter is return code or URI to internal redirect)

If none of the files were found, an internal redirect to the uri specified by the last parameter is made.

Solution 2:

As others have stated, this is the culprit:

    try_files $uri $uri/ ;

It creates a redirection loop, since the last parameter of try_files should point to the location if the file isn't found. I solved it by adding a =404, like this:

    try_files $uri $uri/ =404 ;

Tags:

Nginx