Sub topic 12
Deciding what to fix first
This chapter assumes you can read HTTP status codes, know the difference between 301 and 302 redirects, and have a list of problem URLs from a crawler, your server logs, or Search Console. A real site often has hundreds of such URLs, so you need an order of work.
Score each problem on three factors
Rank every problem URL by these factors, in this order:
- Traffic. How many requests or visits does the broken URL get? Count hits from your access log or clicks and impressions from Search Console.
- Inbound links. Do other pages, internal or external, point at it? An external link is worth more than an internal one, because you cannot edit the other site and the link carries authority that a redirect can preserve.
- Source location. Is the bad link on a template, such as a header, footer, or sidebar? One template link can appear on thousands of pages, and fixing it once fixes all of them.
Fix cost matters too. Editing one link in a template is cheap. Writing a redirect rule for a retired section takes more time.
Internal and external broken links
A broken internal link is a link on your own page that points to a 404. You control both ends, so the fix is to edit the link. A redirect is the wrong answer here, because it adds a hop for every visitor.
A broken external link is a link on your page that points to someone else's dead page. Replace it with a working source, link to an archived copy, or remove it.
An inbound broken link is another site linking to a missing page on yours. You cannot edit it, so add a 301 redirect to the closest matching page.
A priority table
| Priority | Situation | Typical action |
|---|---|---|
| 1 | Broken link in a template or navigation | Edit the link once |
| 2 | 404 with external links or steady traffic | Add a one-hop 301 to the best match |
| 3 | Redirect chains on high-traffic URLs | Point the first URL at the final URL |
| 4 | Redirect loops | Fix immediately, since the page is unreachable |
| 5 | Old 404s with no traffic and no links | Leave them, or return 410 |
Loops are rare, but they make a page unreachable, so treat them as urgent even when traffic looks small.
Rank 404s from your log
The access log gives you traffic counts directly. This command lists the 20 most requested paths that returned 404:
awk '$9 == 404 {print $7}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head -20Field 7 is the request path and field 9 is the status code in the common and combined log formats. Compare the result with your crawler's list of URLs that have inbound links. A path that appears in both is a top candidate.
Some 404s are correct
Not every 404 needs a fix. If a page was removed on purpose and has no replacement, a 404 or 410 is the honest answer. Redirecting it to the home page tends to be treated as a soft 404, so it gains nothing.
Exercise
Your crawler reports two problems. A footer link to /pricing-old returns 404 on 4,000 pages. A URL /blog/2019-tips returns 404, has no inbound links, and received 3 hits last year. Which do you fix first, and how?
Show answer
Fix the footer link first. It is in a template, so one edit repairs 4,000 pages. Point it at the current pricing page directly instead of adding a redirect. The /blog/2019-tips URL has almost no traffic or links, so leave it as a 404, or return 410 if the content is gone for good.