Nginx Location Matching Checklist for WordPress and Apps

halfbrain_logo512adminJune 19, 2026
2 lượt xem

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

  1. List all location blocks in the server block.
  2. Identify exact, prefix and regex locations.
  3. Check WordPress root location.
  4. Check PHP location.
  5. Check static file locations.
  6. Check uploads or protected paths.
  7. Check API or webhook paths.
  8. Check location ordering and regex behavior.
  9. Test affected URLs with curl.
  10. 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.

Checklist Type Technical Setup
Level Intermediate
Risk Level High Risk
Estimated Time 45–90 minutes

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

  1. List location blocks.
  2. Classify location types.
  3. Check root location.
  4. Check PHP location.
  5. Check static locations.
  6. Check protected paths.
  7. Check API paths.
  8. Review matching order.
  9. Test URLs.
  10. Document route map.

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

Share:

Disclaimer: The guides, checklists, commands, and examples on HalfBrain.net are provided for educational and operational reference only. Server environments, hosting providers, software versions, security settings, and WordPress configurations can vary, so you should always review commands before running them on your own system. We do our best to keep the content accurate and useful, but we cannot guarantee that every command, configuration, or recommendation will fit every environment. Always back up your website, database, and server configuration before making changes. HalfBrain.net is not responsible for data loss, downtime, security incidents, misconfiguration, or other issues that may result from applying the information on this website. Use the material at your own discretion.

Leave a Reply

Your email address will not be published. Required fields are marked *