When several systems can issue a URL redirect, the result depends on where the request is handled, which rule matches first, and whether another layer receives the redirected request. This guide explains redirect precedence across DNS, CDNs, web servers, WordPress and application code, then gives you a repeatable way to find conflicts before they become redirect chains, loops or incorrect SEO signals.
Overview
A redirect is not evaluated by one universal rulebook. A request may pass through domain or DNS services, a CDN or edge platform, a load balancer, a web server such as Apache or Nginx, a content management system and application code. Each layer has its own matching syntax and processing order.
The practical rule is to identify the earliest layer that can respond. If Cloudflare returns a redirect at the edge, the request may never reach Apache or WordPress. If the CDN forwards the request to your origin, the origin can then apply its own rules. A redirect response can also create a new request, which may be evaluated again by every relevant layer.
Do not assume that placing a rule in a familiar dashboard makes it the controlling rule. First document the request path through your stack. For example:
- DNS resolves the hostname; it normally does not decide an HTTP redirect.
- The CDN, proxy or load balancer may apply an edge redirect.
- The origin web server evaluates Apache or Nginx configuration.
- WordPress or another CMS may process the request if the server passes it to the application.
- Application code may issue a final redirect after routing or authentication logic.
This is a model rather than a promise that every stack uses every layer. Check your own hosting and proxy configuration before changing a rule. For a broader comparison of implementation choices, see Apache, Nginx, Cloudflare and WordPress redirects.
A practical precedence comparison
| Layer | Typical role | What usually determines precedence | Common conflict |
|---|---|---|---|
| DNS | Points a hostname to a service | DNS records and provider behaviour | Assuming DNS can perform a path-level redirect |
| CDN or edge proxy | Handles requests before the origin | Rule priority, expression order or dashboard order | HTTPS or hostname rule masking an origin rule |
| Load balancer | Routes traffic between origins | Listener, host and path conditions | One listener redirects while another forwards |
| Apache or Nginx | Returns server-side redirects or serves content | Configuration context, match order and rewrite processing | Broad rule catching a URL before a specific rule |
| WordPress or CMS | Handles CMS routes and plugins | Plugin hooks, canonical logic and application routing | CMS redirect repeating or overriding server logic |
| Application code | Redirects based on business or session logic | Code path and conditional order | Legacy URL logic conflicting with language or login redirects |
The exact evaluation rules vary by product and release. Treat the table as a troubleshooting map, not a substitute for the documentation of your platform.
What to track
Keep a small redirect register rather than relying on memory or scattered configuration files. For each rule, record the source pattern, intended destination, status code, owning layer, reason, date added and review date. Include whether the rule is exact, prefix-based, regular-expression based or dependent on a query string.
Track these variables during routine reviews:
- Matching scope: hostname, scheme, path, trailing slash, case sensitivity and query-string behaviour.
- Rule order: which specific exceptions appear before broad HTTP to HTTPS, www to non-www or language rules.
- Status code: use a permanent redirect only when the change is intended to persist; use a temporary redirect for a genuinely temporary condition. Review 301 versus 302 redirects when the purpose of a rule changes.
- Destination quality: final status, hostname, scheme, path and whether the destination is relevant rather than merely reachable.
- Hop count: flag a source that redirects through another redirect before reaching the final URL.
- Response headers: record the Location header, cache headers, server or edge identifiers and any tracing headers exposed by your stack.
- Ownership: identify who can change the rule and where its configuration is stored.
Separate canonicalisation rules from campaign routing and application decisions. A marketing URL with UTM parameters may need tracking, but it should not accidentally trigger a broad rule that strips parameters or sends visitors through multiple hosts. Also check for unsafe user-controlled destinations; the open redirect checklist covers that separate security concern.
Cadence and checkpoints
Review redirect behaviour monthly or quarterly, depending on how often your site changes. A quarterly review may be sufficient for a stable site; a busy migration, platform change or campaign programme warrants a review after each release.
Use this checkpoint sequence:
- Inventory: export or list rules from the CDN, web server, CMS plugins and application repository.
- Normalise: compare rules in a common format: source, condition, status, destination and layer.
- Sort: place exact legacy URLs and narrow exceptions before broad patterns in the layer that evaluates them.
- Test: check representative URLs for HTTP and HTTPS, both hostnames, language paths, trailing-slash variants and known legacy URLs.
- Record: save the date, expected result, observed headers and any change made.
For a migration, use a proper redirect map and test samples from every important URL group. Do not delete old rules simply because a new broad rule appears to cover them; first confirm that it preserves the intended destination and status.
How to interpret changes
Start with the first response, not only the final page. A command-line check makes each hop visible:
curl -I https://example.co.uk/old-page
curl -sSIL https://example.co.uk/old-page
Look at each HTTP/ status line and Location: header. The first command shows the initial response; the second follows redirects and displays the sequence on many systems. If your environment adds authentication, bot protection or a special host header, repeat the test under representative conditions.
Typical findings point to different causes:
- Unexpected edge redirect: inspect CDN rules and priority before changing the origin.
- Two hops for one canonicalisation change: make the first rule point directly to the final HTTPS and hostname combination where practical.
- Redirect loop: compare the condition and destination at every layer. A proxy may believe the request is HTTP while the origin sees HTTPS, or two hostname rules may send traffic in opposite directions.
- Legacy URL reaches the wrong language: test the legacy mapping before the general language rule, and decide whether language selection belongs at the edge, server or application layer.
- 200 response after an old URL: verify whether the application is serving a fallback page instead of issuing the intended redirect.
When a rule appears correct but the old result persists, consider caching. Redirect responses can be cached by browsers, CDNs or other intermediaries. Clear or wait out the relevant cache only after confirming the configuration, and use the guide to diagnose cached redirect responses.
When to revisit
Revisit redirect precedence after a hosting move, CDN adoption, domain change, HTTPS rollout, WordPress plugin change, web server configuration update or application routing release. It should also be part of a migration close-out, not an afterthought. A growing redirect file, a new redirect chain in monitoring or a sudden change in destination URLs is a reason to review sooner than the normal monthly or quarterly checkpoint.
Keep a small test set that remains useful over time: one HTTP URL, one HTTPS URL, both www and non-www variants, a trailing-slash pair, one URL per language path, several legacy URLs and a URL containing tracking parameters. Run it after each relevant deployment and compare status codes, hop counts, final destinations and response headers.
Finally, make one layer the clear owner of each redirect purpose. For example, let the edge handle global hostname and scheme normalisation, the web server handle stable file or path migrations, and the application handle decisions that require user or business context. The exact allocation can differ, but duplicated ownership is the condition most likely to create conflicting redirect rules. If a test fails, trace the request from the earliest responding layer, correct the narrowest rule first, then rerun the full set rather than testing only the URL that exposed the problem.