// blog / indexing

How I fix 404 errors in WordPress with the right redirect for each URL

To fix 404 errors, I sort them by value first, because most don't need fixing at all. The ones that matter have backlinks, impressions or internal links pointing at them. Each of those gets a 301 to the closest matching page, a 410 if it's gone for good, or stays a 404. None go to the homepage.

By Muhammad Younus Updated 10 min read Indexing

Indexing and Search Console: illustration for "Fixing 404 errors with the right redirect"
// 01 - triage first

Which 404 errors are actually worth fixing?

Fewer than the report suggests. A 404 appears when the server can't find anything at the requested address, and a WordPress site that's been live for a few years collects them from everywhere: addresses a bot guessed, links somebody typed wrong, deleted posts, old feeds and attachment pages nobody opens. Fixing every row wastes a day, so I sort the list by value first, which is where crawlability and indexing fixes should start.

Google's help for the Page indexing report is blunt about it: 404 responses aren't necessarily a problem if the page was removed without any replacement. Its HTTP status documentation adds that 4xx codes, other than 429, have no effect on crawl rate. A 404 becomes a fault when something of value still points at it.

The three signals that make a 404 worth a decision
SignalWhere I find itWhy it matters
Impressions or clicksSearch Console's Performance report, filtered by pageGoogle was showing that URL to searchers, so there's demand the site is now throwing away
Links from other sitesSearch Console's Links report and a backlink exportPeople still follow those links, and every one of them lands on a dead end
Links from your own pagesA crawl of the live siteIt's a broken path you control, and it can be fixed at the source

A dead URL with none of the three can usually stay a 404. A URL with any of them gets its own decision, which is the rest of this post.

// 02 - rewrite rules

How do I fix 404 errors on WordPress pages that still exist?

Usually by rebuilding the rewrite rules, not by adding redirects. When posts and pages return 404 but the homepage works, the content's fine and WordPress has lost the rules that map its permalinks to it. I open Settings, then Permalinks, and click Save Changes without changing anything. WordPress's documentation says that if .htaccess is writeable you'll see "Permalink structure updated", and if it isn't, the screen shows the rewrite rules to paste in yourself. It also notes that just visiting the Permalinks screen flushes the rewrite rules.

If that doesn't clear it, I open .htaccess itself. On Apache the WordPress block sits between # BEGIN WordPress and # END WordPress, and WordPress's server docs print the default block in full so a file a plugin has damaged can be restored. The host also needs mod_rewrite, which is on WordPress's own list of what to ask a host for.

// pro tip

This is the one kind of 404 where a redirect is the wrong fix. The URLs are right, so redirecting them only hides a broken setup that'll break the next page you publish too.

// 03 - the homepage question

Should I redirect a 404 to the homepage?

No. It's a popular shortcut, and it doesn't fix anything. Google's site move guidance says not to redirect many old URLs to one irrelevant destination, such as the home page, because it can confuse users and might be treated as a soft 404 error. That means the redirect keeps none of what the old page had and adds a hop on top. The visitor doesn't win either: someone who clicked a link about one product and lands on a homepage has to start again.

I've had to make this call on my own site. When I retired its old pages, they pointed at the homepage while their replacements were being written, and my redirects file records that they held 4,791 impressions between them. Each page that had a replacement was remapped to it as soon as the replacement existed.

The same logic saved a store. On one WooCommerce catalogue, a redesign that renamed URLs with no redirect map cut daily clicks from 162 to 49 in three days. In the recovery the old sapphire category pointed at the new sapphire category rather than the homepage, every other old URL got a 301 to its closest new page, and clicks were back at 362 a day.

// watch out

Plugins that send every 404 to the homepage exist, and they make the Search Console list look clean. The list shrinks because the errors turn into redirects Google may read as soft 404s, not because anything got fixed.

Rather have me do this? One person, whole job.

Book a call on Upwork
// 04 - the decision

How do I choose between a 301, a 410 and leaving the 404?

I ask these in order, and the first one that's true decides the URL.

  1. i.

    The same page lives at a new address

    A changed slug, a new permalink structure or a product that moved category. That's a 301 to the new URL, which Google says tells its indexing pipeline the target should be canonical.

  2. ii.

    It was merged into another page

    Two thin posts folded into one, or an old product replaced by its successor. The 301 goes to the page that absorbed it, but only if that page answers what the old one did.

  3. iii.

    It's retired on purpose and nothing's close

    An old event, a dropped service or a product line that's gone. I return a 410 when the removal is deliberate, or leave the 404. Google treats every 4xx except 429 the same, so the 410 is a note for whoever reads the logs later. Choosing what to remove is a pruning decision with its own rules.

  4. iv.

    It never really existed

    Bot probes for files the site never had, spam links with random strings on the end, a mangled query. These stay 404.

  5. v.

    The broken link is on your own site

    Fix the link first, then decide about the URL. A menu item or a post that still points at a dead address should point at the live one.

// 05 - in wordpress

How do I fix a 404 error in WordPress with a 301?

To redirect a page in WordPress when there's only a handful of URLs, a plugin's the practical route. This is the order I work in.

  1. Step 01

    Check whether WordPress already handles it

    When a post's slug changes, WordPress remembers the old one, and its wp_old_slug_redirect function sends a 301 to the current permalink. A second rule on top only adds a chance of a loop.

  2. Step 02

    Add the rule in a redirect manager

    Most SEO plugins and every dedicated redirect plugin have one. The Redirection plugin is one example: it creates 301s and keeps a log of the 404s it sees. I enter the old path, the new URL and 301, nothing else.

  3. Step 03

    Point at the final URL

    If the target itself redirects, the new rule creates a chain. Google can follow up to 10 hops but advises redirecting straight to the final destination, so I update older rules too.

  4. Step 04

    Update the links that still use the old URL

    Menus, buttons and links inside posts should carry the new address. The redirect's the safety net for links you don't control.

  5. Step 05

    Test the real response

    I request the old URL with curl -I and look for a 301 with a Location header naming a page that answers 200. A plugin screen only shows what was saved, not what the server sends.

A platform move is where all of this happens at once, and I've written up how I build the redirect map when a Wix site moves to WordPress.

// 06 - server or plugin

When is the server a better place for redirects than a plugin?

A plugin rule runs inside WordPress, so the request has to load PHP and WordPress before the redirect answers. For a few dozen rules that's fine, and the owner can see and edit them. A server rule in Apache or Nginx answers before WordPress starts.

Where I put a redirect, and why
SituationWhere the rule goesWhy
A handful of changed posts or productsA redirect pluginThe owner can read and change it without server access
Hundreds of URLs that follow one pattern, like a changed permalink baseOne pattern rule on the serverA single rule replaces hundreds of rows, and nothing waits on WordPress to load
Addresses WordPress never served, like old static files or another platform's pathsThe server configThose requests may not reach WordPress, so a plugin can't answer them reliably
Removals you want marked as goneApache's Redirect gone, or an Nginx return 410Both send a 410 directly, without building a page first

Apache's Redirect directive takes permanent for a 301 and gone for a 410, and Nginx's return directive takes a status code plus a URL for the redirect codes. My own site keeps every redirect in one server-side file, with a comment above each block saying why it's there, because when nobody knows why a rule exists, nobody dares delete it.

// 07 - the 404 page

What should a custom 404 page show?

A way back into the site, and an honest status code. MDN's advice is that custom 404 page design is a good thing in moderation: make it human if you like, but don't confuse visitors about why they're seeing it. I'd give it a plain line saying the page isn't here, a search box and links to the pages people most often want.

On a classic theme, WordPress looks for the theme's 404.php template and falls back to index.php, so that's the file to edit. Then I test it with a made-up URL. It has to answer 404, not 200, because a friendly not found page served with 200 is exactly what Google reports as a soft 404.

// 08 - beyond search console

How do I find 404s that Search Console doesn't show?

Search Console only reports URLs Google has tried to fetch, and its exports are cut to 1,000 rows of representative examples. On a big WordPress site that isn't the whole list, so I pull from four other places.

A 404 log. Some redirect plugins record every 404 as it happens, which shows what real visitors hit.

Server access logs. Every request is in there, including crawlers other than Googlebot and files WordPress never served.

A crawl of the site. It finds internal links to dead pages, the cheapest 404s to fix.

Backlinks. Google says its Links report is a sample, not every link. A backlink export fills the gaps, and any dead URL with outside links goes to the top of the list.

Once the rules are live, old URLs moving into Page with redirect means Google has found them. If new URLs then sit in Discovered or Crawled, currently not indexed, that's a separate problem.

// when to hand this over

If Search Console's 404 list keeps growing and you'd rather one person sorted it by value, decided each URL and tested every rule, that's part of the crawl and indexing work I do, remotely. Nothing on the site changes until you've seen the map.

Book a call on Upwork

Is this your site? Send me the URL.

Book a call on Upwork
// questions - indexing

What else do people ask about this?

Does a 404 error mean I was blocked?

No. A 404 means the server found nothing at that address. A block usually comes back as a 403 Forbidden, which MDN describes as the server understanding the request but refusing it. MDN also notes some servers send a 404 instead of a 403 to hide that a page exists.

Do 404 errors hurt my WordPress site's rankings?

Not on their own. Google removes the missing URL from its index, but it says 4xx codes other than 429 don't affect crawl rate. The damage is local: whatever that URL had earned, clicks or links, is lost unless a relevant page takes it over.

Should I use a 410 instead of a 404?

For Google it makes little difference, since it treats every 4xx except 429 the same way. I use a 410 when a removal is deliberate, because it tells the next person reading the logs that the page wasn't lost by accident.

How long should a 301 redirect stay in place?

Google's site move guidance says as long as possible, generally at least a year. While outside links still point at the old address I rarely remove one at all, since an idle rule costs next to nothing to keep.

Can a plugin fix every 404 automatically?

It can hide them, and that isn't the same thing. A rule that sends every 404 to the homepage turns real errors into likely soft 404s and keeps none of the old page's value. The decision per URL is the fix; the plugin's just where it gets typed in.

// sources - checked

Where do these rules come from?

Platform and Google documentation, opened and read on the day this was written. Everything else is how I work.

  1. Google Search Central: redirects and Google Search
  2. Google crawler documentation: how HTTP status codes affect Google's crawlers
  3. Google Search Central: site moves with URL changes
  4. Search Console Help: Page indexing report
  5. Search Console Help: Links report
  6. Search Console Help: export data directly from a report
  7. WordPress.org documentation: Settings Permalinks screen
  8. WordPress Advanced Administration Handbook: Apache HTTPD and .htaccess
  9. WordPress.org: requirements
  10. WordPress Theme Handbook: template hierarchy
  11. MDN: 404 Not Found
  12. MDN: 403 Forbidden
  13. WordPress developer reference: wp_old_slug_redirect()
  14. WordPress.org plugin directory: Redirection
  15. Apache HTTP Server documentation: mod_alias Redirect directive
  16. Nginx documentation: ngx_http_rewrite_module return directive
Muhammad Younus, WordPress technical SEO consultant
// who wrote this

One consultant, writing down his own method

I'm Muhammad Younus, a WordPress technical SEO consultant with 8+ years of experience and 100+ client sites fixed. Top Rated Plus on Upwork with a 100% Job Success Score. Every post here is the way I actually do the job, written in the first person because it's one person doing it, remotely, with no team behind the name.

Nothing in these posts is a client I can't name or a number I can't show. Where a figure comes from a client's Search Console, it's from a published case study, and where a rule comes from Google or a platform, the source is linked at the bottom of the post.

// the service behind this post
Muhammad Younus smiling and giving a thumbs up
// next step

Want this done on your own site?

Book a call on Upwork, send the URL and read-only Search Console access, and you'll get a written scope for the search side before any work starts. One person does the whole job, remotely.

Book a call on Upwork