If you have ever deleted a page in WordPress and noticed that its old “pretty URL” does not return a 404, but instead redirects to the homepage, you are not alone.
This is a well-known WordPress behavior that frequently causes confusion—and worse, SEO problems. In this article, we will explain:
-
Why WordPress behaves this way
-
Why redirecting deleted URLs to the homepage is a bad idea
-
How to force WordPress to return real 404 errors
-
Best practices for handling deleted content correctly
The Problem: Deleted Pages Redirect to Homepage
Scenario:
-
You delete a page or post in WordPress.
-
You visit its old URL, for example:
-
Instead of seeing a 404 page, WordPress:
-
Redirects to
/ -
Returns HTTP 200
-
Or performs a silent canonical redirect
-
This creates what search engines call a soft 404.
Why This Happens in WordPress
This behavior is not a bug, but a consequence of how WordPress resolves URLs.
1. WordPress Rewrite & Query Resolution
When a request comes in, WordPress:
-
Matches the URL against rewrite rules
-
Tries to resolve it as:
-
A page
-
A post
-
A taxonomy
-
A fallback query
-
-
If nothing matches cleanly, WordPress may treat the request as the front page query
Result: homepage content with a 200 OK response.
2. Canonical Redirects (redirect_canonical())
WordPress uses redirect_canonical() to “fix” URLs it thinks are invalid or malformed.
In many cases, this function:
-
Assumes the URL should resolve somewhere
-
Redirects unknown slugs to the homepage
3. Theme or Plugin Interference (Very Common)
Many themes or plugins contain logic similar to:
This is incorrect behavior and silently converts real 404s into homepage redirects.
SEO plugins and page builders are frequent culprits.
Why This Is Bad for SEO
Redirecting deleted content to the homepage causes:
-
Soft 404s in Google Search Console
-
Index bloat
-
Loss of crawl budget
-
Poor user experience
-
Lower trust signals for your domain
Google explicitly recommends returning a real 404 when content no longer exists and has no replacement.
How to Fix It: Force Proper 404 Responses
✅ Solution 1 (Recommended): Disable Canonical Redirects for 404s
Add this snippet to functions.php or a small custom plugin:
This prevents WordPress from auto-redirecting missing URLs.
✅ Solution 2: Force 404 When No Posts Are Found
This ensures deleted slugs always return a real 404 response.
✅ Solution 3: Handle Deleted Pages Explicitly
If the issue mainly affects pages (not posts):
Check Your Theme (Critical Step)
Before adding code, inspect your theme for:
-
wp_redirect( home_url() ) -
template_redirecthooks -
pre_get_postsfilters
Any redirect triggered on ! have_posts() should be removed.
This is the number one hidden cause of homepage redirects.
How to Verify the Fix
Run:
Correct response:
Incorrect responses:
Best Practice for Deleted Content
| Situation | Correct HTTP Status |
|---|---|
| Deleted content, no replacement | 404 |
| Deleted content with new equivalent | 301 redirect |
| Temporarily unavailable | 503 |
| Mistyped or invalid URL | 404 |
Redirecting everything to the homepage is never recommended.
Conclusion
-
This is a known WordPress behavior
-
Homepage redirects for deleted URLs are wrong
-
Proper 404 handling improves SEO and UX
-
The fix is straightforward and safe when implemented correctly
If you want a theme-safe, plugin-safe snippet tailored to your setup (theme name + SEO plugin), feel free to ask.