i have two locations in nginx location /print2 { return 301 $argsitepath; break; }…
- User
i have two locations in nginx
location /print2 { return 301 $arg_site_path; break; }
location ~ ^(.*)/print2$ { return 302 $1; }why is it always fires second for url like domain.com/print?site_path=/news.html ?
- Assistant
When you have multiple location blocks in NGINX, the server processes the requests and tries to match the URI against each location block according to certain rules. The
locationdirective comes in different flavors, primarily standard prefixes, exact matches, and regular expressions, with regular expressions having the highest precedence.