Documentation sections

Check Next.js redirects and canonical URLs

Trace one deployed URL. Confirm it lands where you expect, then read the canonical link in the final page. Use Betterloop’s free checker from your browser. No account or SDK needed.

Check a public URL

Trace a working example

Copy the command into a terminal. Then replace the first URL with a public page on your own deployment. The output shows each HTTP response and redirect destination, followed by the canonical link and the final status and URL.

page='https://betterloopai.com/docs/?utm_source=redirect-example'
curl -fsSL --max-time 20 --max-redirs 8 -D - \
  -w '\nFINAL %{http_code} %{url_effective}\n' "$page" |
  tr -d '\r' |
  grep -ioE '^HTTP/[^ ]+ [0-9]+|^location:.*|<link rel="canonical"[^>]*>|^FINAL .*'

Betterloop’s docs return 308 to the version without the trailing slash, then 200. The final address keeps the query. The canonical link points to https://betterloopai.com/docs without the tracking parameter. If the command misses your canonical link because of its attribute order or quotes, find rel="canonical" in the final page’s HTML.

Find the setting to change

  • Unexpected landing address. Check trailingSlash, redirects in next.config, and any rules set at your host. Retest the same URL after deploying the change.
  • Unexpected canonical link. Check metadata.alternates.canonical or generateMetadata() in the App Router. The canonical link signals the preferred address to search engines. The HTTP response determines where visitors land.
  • Only some URLs are affected. Repeat the check for a dynamic page and an alias or tracked link that visitors actually use.

Read the official Next.js references on trailing slashes and canonical metadata.