I'm trying to rationalize my Nginx server config, but I have a rather dumb question that I couldn't solve. So, here is the question : is try_files
parsed before or after rewrite
? Asked differently, Do I have to put try_files
after all rewrite
directives, or is Nginx config parser smart enough to evaluate try_files
after all relevant rewrite
directives ?
The link with the config rationalization is that the answer to this question will change the organisation of the config, ie if config file order of try_files
and rewrite
changes the config behaviour, it will force me to disperse my includes, some of them containing try_files
and other ones containing rewrite
, because I also have rewrite
directly in nginx.conf
.
Nginx process request in phases, and
rewrite
's phase is always beforetry_files
phase. Therefore the order of these directives in config doesn't matter.