Sub topic 13
Fixing the link, the redirect, or neither
This chapter assumes you can read HTTP status codes, know the difference between 301 and 302, and can trace a URL with curl. It covers what to do once you have a prioritized list of problem URLs.
Three possible fixes
Each broken or redirecting URL gets one of three treatments. Pick by asking where the problem lives and whether the content still exists.
| Situation | Fix | Result |
|---|---|---|
| An internal link points at a URL that redirects or errors | Edit the link to the final URL | No extra request, no redirect needed |
| An old URL has traffic or external links, and a replacement exists | Add a 301 to the final URL | One hop, link value passes on |
| The content is gone and has no replacement | Return 410 (or 404) | Clear signal, no misleading redirect |
Fix the source link first
Internal links are under your control, so correct them at the source. A link to /old-page that redirects to /new-page works, but it costs every visitor and crawler an extra request. Change the href in the page, template, or menu. Search your content for the old path, because the same link often appears in many places.
Keep the redirect afterward if outside sites, bookmarks, or search results may still use the old URL.
Collapse chains into one hop
A chain such as /a to /b to /c should become /a to /c and /b to /c. Trace each starting URL, note the final destination, and point every old URL there directly. Update the rule that creates the first hop, not just the last one.
# Before: /a -> /b, and /b -> /c (two hops)
# After: both go straight to /c
location = /a { return 301 /c; }
location = /b { return 301 /c; }Apache needs the same treatment with Redirect 301 /a https://example.com/c. Afterward, re-run the trace to confirm one hop:
curl -sL -o /dev/null -w '%{num_redirects} redirects, final status %{http_code}, final URL %{url_effective}\n' https://example.com/aYou want 1 redirects, final status 200.
When neither fix is right
Do not redirect everything to the home page. A redirect from a removed page to an unrelated page is often treated as a soft 404, and it confuses users. When content is permanently gone and nothing matches it, serve 410 Gone, or 404 if you are less certain. Both are honest answers.
For broken links on external sites that point at you, redirect only if a close replacement exists. For broken outbound links on your pages, replace them with a working source, link to an archived copy, or remove the link.
Verify after every change
Re-trace the old URLs and re-crawl the affected section. Check three things: the status of the final URL is 200, the hop count is one, and no internal link still points at a redirecting URL.
Exercise
Your crawler reports that 40 internal pages link to /pricing-old, which returns a 301 to /pricing. Nobody outside your site links to /pricing-old. What do you do?
Show answer
Update the 40 internal links (or the template that produces them) to point at /pricing, then re-crawl to confirm none remain. Keeping the 301 is optional but harmless. It protects any old bookmarks, so you can leave it in place.