Sub topic 12
Deciding what to fix first
This chapter assumes you can already produce a list of problem URLs. That means a crawler export (see "Crawling your site to find broken links"), server log counts, and Search Console reports. It also assumes you know the difference between a 404, a 410, a redirect chain, and a soft 404. A first crawl of a mature site often returns hundreds of problems. You will rarely fix them all, so the order in which you fix them matters.
Why a flat list misleads you
A crawler reports every broken URL as one row, with no indication of how much each one matters. A dead link in a 2014 blog comment and a dead link in your main navigation look the same in the export. Three kinds of noise inflate the list:
- Probe traffic. Bots request paths like
/wp-login.phpor/.envon every site. These 404s are correct behavior and need no fix. - Duplicates by source. One broken URL linked from 400 pages is one fix, not 400.
- Low-value URLs. Old tag pages, expired campaign links, and parameter variants often have no traffic and no inbound links.
Prioritizing means turning the list into a ranked queue where each item is weighed by cost of the problem against effort of the fix.
The signals that matter
Collect the same four or five signals for every problem URL, then compare.
| Signal | Where it comes from | What it tells you |
|---|---|---|
| Requests in the last 30 days | Server logs | How often users and bots actually hit the URL |
| Internal links pointing to it | Crawler "inlinks" report | How many fixes you control, and how much navigation is affected |
| External links pointing to it | Backlink tool, Search Console Links report | Link equity being lost, and fixes you cannot make at the source |
| Search impressions or clicks | Search Console Performance report | Whether the URL still ranks or ranked recently |
| Error class | Status code | 5xx and chains differ from 404s in urgency |
External inbound links deserve extra weight. You cannot edit another site's page, so a redirect from the dead URL is the only way to recover that value. Internal links are the opposite. You can fix them at the source in one commit, which also removes the redirect hop for every visitor.
Pull the numbers from your logs
The access log gives request counts per broken URL. This command lists the 20 most requested paths that returned 404, assuming the common or combined log format:
awk '$9 == 404 {print $7}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head -20Field 9 is the status code and field 7 is the request path. Review the top of this list manually. Anything that looks like /wp-admin, /xmlrpc.php, or /.git/config is probe traffic, and you can skip it.
A triage order
Work in tiers, not in strict score order. Some problems outrank any score.
- Server errors (5xx) on real pages. A 500 or 503 on a page that should exist means the page is unavailable now. Fix these before any link work, and check whether they are intermittent or persistent.
- Broken links in global templates. A dead link in the header, footer, or sidebar appears on every page. One template edit removes thousands of crawler rows.
- Broken URLs with external links or search traffic. Add a one-hop 301 to the best replacement page.
- Redirect loops. A loop never resolves, so the URL is effectively a 5xx for users. Loops are rare, so they are quick to find and fix.
- Redirect chains on high-traffic paths. Collapse them to one hop. Each extra hop adds latency and a chance of failure.
- Soft 404s. Pages that say "not found" but return 200 waste crawl budget and can pollute the index. Fix the status code or the content.
- Long-tail 404s with no traffic and no links. Leave these as 404, or return 410 if you know the content was removed on purpose.
Scoring URLs with a script
Once you have more than a few dozen rows, a simple score keeps you consistent. The script below weights external links most, because you cannot fix them at the source, and filters probe paths before ranking. The data is inline so the script runs as shown.
import csv
import io
DATA = """url,requests_30d,external_links,internal_links
/old-pricing,420,12,3
/blog/2019/tips,35,8,0
/press-kit.zip,80,5,0
/wp-login.php,900,0,0
"""
IGNORE_PREFIXES = ("/wp-", "/xmlrpc", "/.env", "/.git")
def score(row):
return (
int(row["requests_30d"])
+ 20 * int(row["external_links"])
+ 5 * int(row["internal_links"])
)
rows = [
r for r in csv.DictReader(io.StringIO(DATA))
if not r["url"].startswith(IGNORE_PREFIXES)
]
for row in sorted(rows, key=score, reverse=True):
print(f"{score(row):>5} {row['url']}")The output is:
675 /old-pricing
195 /blog/2019/tips
180 /press-kit.zip/wp-login.php has the most requests but is dropped by the filter. /blog/2019/tips has few visits but ranks above /press-kit.zip because eight external sites link to it.
Edge cases
- Recent traffic spikes. A URL with 5,000 hits in two days may come from a newsletter or social post with a typo in the link. Check the referrer in the logs. Fix it fast, because the spike will fade and the score will not show it.
- Old URLs with a long history. A page that ranked for years and then 404'd may still hold strong signals. Check Search Console for past impressions before deciding it is low value.
- Many sources, one target. If one dead URL has 200 internal links, fix it with a search-and-replace in the content or database, then add a redirect for external visitors.
- No good replacement. Do not redirect everything to the homepage. Search engines may treat a redirect to an unrelated page as a soft 404. If no relevant page exists, return 404 or 410.
- Staleness. Crawler data and log data cover different time windows. Re-run both before acting on a report that is more than a few weeks old, or you may fix links that someone already repaired.
Summary of decisions
Rank by impact and by how much of the fix you control. Handle server errors and template links first, because they affect the most users per change. Use redirects for URLs that other sites link to. Leave true long-tail 404s alone. The next chapter covers how to carry out each of these fixes.
Exercise
Your crawl shows two broken URLs. URL A returns 404, gets 600 requests a month, and has no inbound links. Every request comes from paths like /wp-admin/setup-config.php. URL B returns 404, gets 40 requests a month, and has 15 external links. Which do you fix first, and how?
Show answer
Fix URL B first. URL A is probe traffic from bots scanning for WordPress installs, so the 404 is correct and needs no action. URL B has 15 external links, and you cannot edit those pages, so add a one-hop 301 redirect from URL B to the most relevant replacement page. That preserves the link value and sends visitors to useful content.
Exercise
A dead link in your site footer appears in the crawl report as 1,800 separate rows. How many fixes does this need, and why does that change its priority?
Show answer
It needs one fix: edit the footer template. All 1,800 rows share a single source, so one change removes them all. That makes it a high-priority, low-effort item, ahead of problems that need a separate change for each URL.