webzod
account

Shorten the redirect chain on nginx

headers.redirect.too_long · effort: minutes

Why it matters

The page is reached only after more redirects than our scanner follows (5), and each hop adds a round trip for visitors and crawlers. Usually http, www, a trailing slash and a language prefix are each redirected in a separate step; send the first request straight to the final address.

The fix

  1. Redirect each name to the final address in one return, not to an intermediate one that redirects again; run sudo nginx -t and reload.
nginx
server {
    listen 80;
    listen [::]:80;
    server_name example.com;
    return 301 https://example.com$request_uri;
}

The examples use example.com. Replace it with your own domain.

Read the documentation (opens in a new tab)

Scan your domain to see whether this applies to you.