Process Flow - Location matching priority order
Request URL arrives
Check exact match (=)
Use exact location
No
Check prefix match (^~)
Use prefix location
No
Check regex matches (~ or ~*)
Use first regex match
No
Use longest prefix match
Serve request with matched location
Nginx checks locations in this order: exact match first, then prefix with ^~, then regex, and finally longest prefix match.