Back to Index
November 13, 20265 min read

Deleting 45 Pages Nearly Created 168 Dead Redirects

This week's task on educollege.in looked simple on paper: delete 45 named university pages, add a Google tag that might already be there, and apply a sheet of 301 redirects someone had put together from Search Console data. All three parts were real, all three were small on their own. The interesting part was where they intersected.

The tag that was already there

First item: a pasted gtag.js snippet for AW-18307592204, with instructions to add it to the layout if it was missing. It wasn't missing — it was already wired in, just not as its own separate <Script> block. A previous pass had consolidated three AW- tags into one shared gtag.js loader plus a combined config block, with a comment explaining exactly why. Adding the pasted snippet verbatim would have reintroduced the duplicate-load problem that consolidation existed to fix. Checking before pasting saved a regression that would have looked completely harmless in the diff.

The sheet's two silent conflicts

The redirect sheet had 5 rows for /universities/... pages. Two of them pointed at pages on the deletion list:

Redirect from sheet Destination Problem
iim-ahmedabad-mba → iim-ahmedabad-online iim-ahmedabad-online is item #13 on the deletion list
iim-raipur-mba → iim-raipur-online iim-raipur-online is item #42 on the deletion list

Adding either redirect as written would 301 a visitor straight into a page that no longer exists. Flagging this and asking "delete them completely, or keep them alive for the redirect?" got a clear answer: delete them completely. That resolved the sheet conflict, but it opened a bigger question I hadn't asked yet.

The question the sheet never raised

next.config.ts already had 282 redirect rules before this task touched it — course-level sub-pages like /universities/iim-raipur-online/mba that redirect up to their parent university page. Once iim-raipur-online and the other 40 base slugs are gone, every existing rule that redirects into one of them becomes a 301 into a 404.

Grepping every redirect's destination against the 41 deleted base slugs turned up 168 existing rules that would break — more than three times the size of the sheet's own request, and never mentioned anywhere in it because the sheet's author was reasoning about new redirects to add, not about the blast radius of a separate deletion list landing in the same change.

destination: '/universities/iim-raipur-online'   <- about to 404, 4 existing rules point here
destination: '/universities/iit-hyderabad-online' <- about to 404, 6 existing rules point here
...168 total

Two different fixes, depending on whether a better destination already existed:

  • iim-ahmedabad-online and iim-raipur-online each had a surviving sibling page (-mba instead of -online) still on the site — those 4 incoming redirects got repointed to the sibling instead of the deleted parent.
  • The other 39 deleted slugs had no sibling to redirect to, so their 164 incoming redirects got repointed to the /universities listing page — the same pattern the codebase already used (via an existing comment) for university cards that exist but were never given real content.

Then, since none of this covered the deleted URLs themselves, each of the 45 original URLs got its own new redirect rule too — so a direct visit or an old backlink lands somewhere real instead of a flat 404. That's 45 new rules, which is not a coincidence: every single item on the original list got accounted for, once as a removed page and once as a redirect.

Verifying it without trusting the diff

tsc --noEmit and eslint both came back clean, but that only proves the file parses — it says nothing about whether a URL actually goes where it should. The real check was starting the dev server and curling the actual paths:

/universities/iit-hyderabad-online        -> 308 -> /universities
/universities/iim-ahmedabad-online        -> 308 -> /universities/iim-ahmedabad-mba
/universities/iim-raipur-online/mba       -> 308 -> /universities/iim-raipur-mba

Two "surviving" pages came back 500 instead of 200, which looked alarming until the stack trace pointed at a fetch failed reaching a CMS manifest endpoint that simply isn't reachable from this machine — nothing to do with the redirect or deletion work. Confirming that meant git stash, re-curling the same URL against the completely unmodified codebase, seeing the identical 500, and git stash pop to restore the real changes. Same failure on a clean tree is the cheapest proof available that a scary-looking error isn't yours.

The lesson

A deletion list and a redirect sheet can each look complete in isolation and still be dangerously incomplete together. The sheet's own 5 university rows weren't the risk — the 282 rules already in production that nobody was looking at when either list was written were. Whenever a change removes a URL, the question isn't just "does anything in this change point there" — it's "does anything that already exists point there," and that search has to run over the full file, not just the lines being added.