You write a rewrite , then a try_files right under it, and you read it as "the rewrite on top runs first, the try_files below runs after. " You put an if inside a location and read it as "when the condition is true, this stuff gets added to the outer config. " Both readings trace the config file ...

Source: [Dev.to](https://dev.to/shinagawa-web/nginx-doesnt-run-your-config-top-to-bottom-two-traps-with-rewrite-tryfiles-and-if-2hlm)

Sponsored