Glossary · Networking

Canonical Redirect

A canonical redirect permanently sends every variant of a URL, such as http, www or trailing-slash versions, to one preferred address.

Updated October 28, 2026

A canonical redirect is a 301 or 308 response that consolidates duplicate addresses of the same content into a single preferred ("canonical") URL. Typical variants it collapses are http versus https, www versus non-www, uppercase versus lowercase and with or without a trailing slash.

Why it matters

Without it, the same page answers on several addresses, which splits link signals, creates duplicate content and gives analytics and caches several entries to track. Search engines can usually work out the preferred version, but a server-side redirect states it unambiguously and also moves real users there. The rel="canonical" tag is only a hint, whereas a redirect is enforced.

Example

An nginx server block that sends everything to https://www.example.com:

server {
    listen 80;
    server_name example.com www.example.com;
    return 301 https://www.example.com$request_uri;
}
server {
    listen 443 ssl;
    server_name example.com;
    return 301 https://www.example.com$request_uri;
}

Each variant reaches the target in one hop, which also avoids a redirect chain.

Common mistakes

  • Redirecting to the homepage instead of preserving $request_uri.
  • Choosing 302 for a permanent decision.
  • Forgetting the HTTPS certificate for the non-preferred hostname, so the redirect itself fails with a certificate error.

Get notified when this term updates

Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.

This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.