404 Error Handling Best Practices

Every website has 404 errors. Content gets removed, URLs change, and external sites link to pages that no longer exist. The difference between a site that...

Dilshad Akhtar
Dilshad Akhtar
Published: 19 June 2026
5 min read
TL;DRAI summary
  • Every website has 404 errors.
  • This is the most important rule.
  • Do not wait for Google Search Console to report 404s.
  • Not every 404 needs a redirect, but many should have one.
  • Your 404 page is not a dead end.
  • Many frameworks support catch-all routes that match any URL pattern.
  • Search engine crawlers behave differently than browsers.
  • Schedule a monthly audit of your 404 landscape.
  • Verify all 404 pages return HTTP 404 status not 200 Implement 410 for permanently removed content Set up server log parsing for 404 detection...

Every website has 404 errors. Content gets removed, URLs change, and external sites link to pages that no longer exist. The difference between a site that loses traffic from 404s and one that preserves it comes down to handling. This post covers the technical and strategic best practices for 404...

Illustration for: Turning Broken Links Into Opportunities

Every website has 404 errors. Content gets removed, URLs change, and external sites link to pages that no longer exist. The difference between a site that loses traffic from 404s and one that preserves it comes down to handling. This post covers the technical and strategic best practices for 404 error handling in 2026.

Always Return the Correct HTTP Status Code

Illustration for: Always Return the Correct HTTP Status Code

This is the most important rule. Your 404 page must return an actual 404 status code. A "Page Not Found" template that returns 200 creates a soft 404, which Google treats as a low-quality page. Verify with a simple curl command:

curl -I https://example.com/this-does-not-exist

The first line of the response should show "HTTP/1.1 404 Not Found" or "HTTP/2 404".

Going Further: 410 Gone

Illustration for: Going Further: 410 Gone

When content is removed permanently and will not return, use a 410 Gone status instead of 404. The 410 status tells search engines the resource was deliberately removed. Google may deindex these pages faster than a 404, which signals "not found now, but maybe later."

Monitor 404s Proactively

Do not wait for Google Search Console to report 404s. Set up active monitoring.

Server logs. Parse your access logs for 404 responses. Track patterns: broken external links, removed internal pages, or malformed URLs.

Custom 404 logging. Add logging to your 404 handler to capture the referrer URL, the requested URL, and the user agent. This data helps you understand who hits broken links and why.

Uptime monitoring. Include specific URL checks for critical paths that should never 404. If they start returning 404, alert immediately.

Redirect Where Appropriate

Not every 404 needs a redirect, but many should have one.

High-traffic 404s. Pages with inbound links from external sites should redirect to a relevant replacement. Losing those links means losing link equity.

Old blog posts. If you removed a blog post, redirect it to a related post or category page. Do not let the link equity go to waste.

Deleted products. Redirect product URLs to the parent category or a similar product. Preserve the user's journey.

Internal links gone stale. When you restructure URLs, implement redirects before removing the old pages. This prevents internal 404s during the transition.

Design a Useful 404 Page

Your 404 page is not a dead end. It is a recovery point.

Keep the header and navigation. Users should be able to click to the homepage, a sitemap, or a search bar without hitting the back button.

Add a search box. The highest converting element on a 404 page is a search field. Give users a way to find what they need.

Suggest popular content. Show links to your top pages or categories. Many users who land on 404 pages bounce to suggested pages at high rates.

Keep it on-brand but simple. Do not confuse users with humor or complex messaging. A clear "Page not found" with immediate options works best.

Include a feedback mechanism. Let users report the broken link. This crowdsources your 404 detection.

Implement Catch-All Routing Carefully

Many frameworks support catch-all routes that match any URL pattern. Configure these carefully.

For known URL patterns. Use catch-all routes only for known patterns like user profiles or product pages. Return 404 for everything else.

Avoid wildcard redirects. A catch-all that redirects every unknown URL to the homepage creates massive confusion for crawlers and users. It also signals to Google that your site has infinite URLs.

Handle Crawler-Specific Behavior

Search engine crawlers behave differently than browsers. They follow every link they find, including broken ones.

Serve 404s for crawlers too. Use the same error handling logic for crawlers and users. Do not cloak different content for crawlers on 404 pages.

Do not monetize 404 pages. Serving ads or affiliate links on 404 pages can be interpreted as cloaking. Google may penalize the practice.

Set Up Regular 404 Audits

Schedule a monthly audit of your 404 landscape. Tools like Screaming Frog, Sitebulb, or Ahrefs crawler provide executable lists of broken links.

For each 404:

  • Is it an internal broken link? Fix the link source.
  • Is it an external broken link worth saving? Implement a redirect.
  • Is it junk traffic (spam, bot noise)? Ignore and monitor.
  • Is it a deleted page with no replacement? Return 410 and move on.

Audit Checklist

  • [ ] Verify all 404 pages return HTTP 404 status (not 200)
  • [ ] Implement 410 for permanently removed content
  • [ ] Set up server log parsing for 404 detection
  • [ ] Create a redirect map for high-value broken URLs
  • [ ] Design a useful custom 404 page with search and navigation
  • [ ] Schedule monthly 404 audits with a crawler tool
  • [ ] Document a 404 handling policy for the development team

Ready to Build Your Dream Website?

Let's discuss your project and create something amazing together.