Nginx Location Matching Checklist for WordPress and Apps
Nginx location blocks decide how different URL paths are handled. A wrong location rule can break WordPress permalinks, static files, PHP execution, uploads, APIs, webhooks or reverse proxy apps.
Core principle
Location matching is route selection inside a server block. Understand which location wins before changing rewrite, try_files, PHP or proxy rules.
Checklist
- List all location blocks in the server block.
- Identify exact, prefix and regex locations.
- Check WordPress root location.
- Check PHP location.
- Check static file locations.
- Check uploads or protected paths.
- Check API or webhook paths.
- Check location ordering and regex behavior.
- Test affected URLs with curl.
- Document which location handles each critical path.
Reusable lesson
This applies to WordPress, Laravel, APIs, n8n webhooks, static assets, admin dashboards, proxy paths and file download endpoints.
When to Use This Checklist
Use this checklist when debugging WordPress permalinks, PHP execution, APIs, uploads, webhooks or path-specific Nginx behavior.
Required Tools
SSH access, Nginx config, affected URLs, curl, access log, error log
Before You Start
Do not add a new location rule until you understand which existing location currently handles the URL.
Structured Checklist Steps
- List location blocks.
- Classify location types.
- Check root location.
- Check PHP location.
- Check static locations.
- Check protected paths.
- Check API paths.
- Review matching order.
- Test URLs.
- Document route map.
Verification Steps
- Critical URLs match intended locations.
- PHP files route to PHP-FPM only as intended.
- Static files serve correctly.
- APIs and webhooks are reachable.
- nginx -t passes after changes.
Rollback Plan
If a location change breaks URLs, restore the previous server block and test one affected path at a time before reapplying a narrower rule.
Common Mistakes
- Adding broad regex locations.
- Breaking PHP handling.
- Blocking uploads unintentionally.
- Forgetting WordPress try_files.
- Not testing all critical URL types.
Related Commands
sudo nginx -T | grep -n "location"
sudo nginx -t
curl -I https://example.com/
curl -I https://example.com/sample-post/
curl -I https://example.com/wp-content/uploads/test.jpg
sudo tail -n 100 /var/log/nginx/error.log