Redirecting 404s to the homepage: find and undo the rule
If every missing URL redirects to your homepage, find the plugin, .htaccess or nginx rule doing it, replace it with a real 404 and test with an invented URL.
By Crawlito · 8 min read
In short
- Google's site move guide says not to redirect many old URLs to one irrelevant destination such as the home page, because it might be treated as a soft 404.
- Blanket 404 redirects can come from four places: a WordPress redirect plugin, an Apache ErrorDocument or RewriteRule, an nginx error_page or try_files line, or a hosting panel that writes to .htaccess.
- Apache's documentation warns that an ErrorDocument pointing to a full URL sends a redirect, so the client never receives the original 404 status code.
- In nginx, error_page with a full URL returns a 302 by default, while try_files ending in =404 returns a real not-found response.
- Request a URL you invented and check the first response: a working setup answers 404 or 410 directly, with no Location header.
On this page
- Why a blanket redirect to the homepage is a problem
- Test first: request a URL that never existed
- WordPress: plugin settings that redirect every 404
- Apache and .htaccess: ErrorDocument and RewriteRule patterns
- nginx: errorpage and tryfiles
- Hosting panels, CDNs and edge rules
- What to put in place instead
- Frequently asked questions
- Check how a missing URL looks to crawlers
If every missing URL on your site lands on the homepage, a rule somewhere is turning 404s into redirects, and you should remove it so missing pages return a real 404 or 410. Google's site move guidance says redirecting many old URLs to one irrelevant destination, such as the home page, might be treated as a soft 404. Look for the rule in four places: a WordPress redirect plugin, Apache configuration, nginx configuration, or a hosting panel. This guide shows how to find each one, what to replace it with, and how to prove the fix with a URL that never existed.
If you want the background on soft 404s in general, soft 404 pages covers diagnosis on any stack, and 410 vs 404 for deleted pages covers which code to pick. This post is about hunting down the catch-all rule.
Why a blanket redirect to the homepage is a problem
Google is specific about this. Its guide to site moves with URL changes says: "Don't redirect many old URLs to one irrelevant single URL destination, such as the home page of the new site." It adds that this can confuse users and might be treated as a soft 404 error. The same page says that content you are not moving should return 404 or 410 on the new site, and that redirecting several old pages to one page is fine when that page genuinely consolidates their content.
Search Console's Page indexing report help recommends returning a 404 for truly not-found pages, and notes that 404 responses are not necessarily a problem when a page was removed without a replacement.
For AI crawlers and assistants, the cost is more direct. A crawler or a user-triggered fetcher that asks for /guides/pricing-2024/ and gets your homepage has received the wrong document under a successful final response. OpenAI, Anthropic and Perplexity do not document how their crawlers treat this case, so the safe assumption is the plain one: a client that follows the redirect sees your homepage content, not a clear signal that the page is gone. If assistants are sending people to URLs you never had, ChatGPT links that 404 covers that separate problem.
Test first: request a URL that never existed
Before changing anything, confirm the behaviour and keep the output as evidence. Use a path nobody could have linked to:
curl -s -o /dev/null -w "%{http_code} %{redirect_url}\n" \
"https://www.example.com/this-page-does-not-exist-7f3k2"A healthy site prints 404 (or 410) and nothing after it. A catch-all redirect prints something like:
301 https://www.example.com/To see every hop and the headers that name the culprit, follow the chain:
curl -sIL "https://www.example.com/this-page-does-not-exist-7f3k2" \
| grep -iE "^(HTTP|location|x-redirect-by|server)"Three details narrow the search:
| What you see | Likely source |
|---|---|
x-redirect-by: WordPress or a plugin name | WordPress or a plugin calling wp_redirect() |
Redirect with no x-redirect-by | Web server rule (.htaccess or nginx), CDN rule, or a plugin that omits the header |
200 with homepage content, no redirect | A fallback that serves the homepage or app shell in place, not a redirect |
The X-Redirect-By header comes from WordPress: the wp_redirect() reference says its $x_redirect_by parameter defaults to WordPress, and callers can pass their own name or omit the header. So the header is a strong hint, not proof, but it tells you whether to start in the WordPress admin or in server configuration.
Repeat the test with an invented URL inside a real section, such as /blog/not-a-real-post-7f3k2/ or /products/not-a-real-item-7f3k2/. Some rules only apply to one path prefix.
WordPress: plugin settings that redirect every 404
WordPress itself returns a 404 for unknown URLs through the theme's 404 template. When it redirects instead, a plugin is usually responsible. List what is active:
wp plugin list --status=activeThen check plugins that offer this behaviour:
- Rank Math (Redirections module). Under Rank Math SEO, General Settings, Redirections, Rank Math's knowledge base describes a Fallback Behaviour setting that can show a 404, redirect to the homepage, or redirect to a custom URL. Set it back to the 404 option. The same page documents Debug Redirections, an admin-only interstitial that shows which rule fired. Turn it on while you test, then off again.
- Redirection (John Godley). Its matching documentation lists a "URL and WordPress page type" match whose only page type is 404, which "allows you to redirect all 404 errors". Look in the redirect list for a rule using that match, or a regex source such as
^/.*or.*that points to/, and disable it. - Single-purpose 404 plugins. Plugins such as All 404 Redirect to Homepage exist to send 404s to the homepage or another page with 301 redirects. Deactivate it, or switch its redirect off in its settings page.
SEO suites and security plugins can also add 404 handling, so if the header names a plugin you do not recognise, search its settings for "404" before looking at the server. After disabling the rule, clear any page cache plugin and CDN cache, because a cached 301 can keep the old behaviour alive.
Apache and .htaccess: ErrorDocument and RewriteRule patterns
On Apache, look for two patterns. Search the site root .htaccess and the virtual host files:
grep -rniE "ErrorDocument|RewriteRule|RedirectMatch" \
/var/www/html/.htaccess /etc/apache2/sites-enabled/ 2>/dev/nullErrorDocument pointing to a full URL
# Problem: sends a redirect, the client never sees 404
ErrorDocument 404 https://www.example.com/Apache's ErrorDocument documentation is explicit: when the document is a remote URL (anything starting with a scheme such as http), Apache sends a redirect, "the client will not receive the original error status code", and this "can confuse web robots". Use a local path instead, so Apache handles the error with an internal redirect to your custom page rather than a redirect sent to the client:
# Fix: local path, handled inside Apache
ErrorDocument 404 /404.htmlApache's custom error responses guide adds one caveat: if the local target is a script, the script should send a Status: header so the error condition reaches the client. If your 404 page is generated by PHP or CGI, run the curl test again to confirm it still returns 404.
A rewrite rule that sends unknown paths to /
# Problem: every path that is not a file or directory gets a 301 to the homepage
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ / [R=301,L]This looks similar to the standard WordPress block, which is why it survives reviews. The difference is the destination and the flag: WordPress's basic .htaccess ends with RewriteRule . /index.php [L], an internal rewrite that lets WordPress decide the status. The rule above has R=301, which tells the client to go to the homepage. Delete it, or restore the standard # BEGIN WordPress block if that is what the site needs. RedirectMatch lines that send a whole section to the homepage, such as RedirectMatch 301 ^/shop/.*$ /, do the same thing and should go too, unless they are scoped to a section you really consolidated.
nginx: error_page and try_files
Search the nginx configuration, including included files:
grep -rnE "error_page|try_files|return 30[12]" /etc/nginx/error_page with a URL
# Problem: redirect instead of a 404
error_page 404 =301 https://www.example.com/;The nginx core module documentation says that when error_page points to a URL, nginx returns a 302 by default and the code can only be changed to another redirect status. Point it at a local URI instead, which nginx handles as an internal redirect:
# Fix: custom page, 404 status kept
error_page 404 /404.html;
location = /404.html {
internal;
}Watch for the =response form too. error_page 404 =200 /index.html; keeps the homepage in place with a 200, which is a soft 404 without any redirect.
try_files that falls back to the homepage
# Problem: unknown paths get the homepage (or an SPA shell) with 200
location / {
try_files $uri $uri/ /index.html;
}The nginx documentation says that if none of the listed files exist, try_files makes an internal redirect to the last parameter, and that the last parameter can also be a status code. For a static site, end with =404:
location / {
try_files $uri $uri/ $uri.html =404;
}For a PHP application such as WordPress, keep the fallback to the application (try_files $uri $uri/ /index.php?$args;) and let the application set the 404. A single-page app that needs the shell fallback has to return the right status from the server for unknown routes; SPA 404 status codes and client routing covers how.
Hosting panels, CDNs and edge rules
If neither WordPress nor your server files show the rule, look at the layers above them.
- cPanel. The cPanel Redirects documentation says redirects added in the interface are placed at the bottom of the
.htaccessfile, and that existing redirects cannot be edited, only deleted and recreated. Check the Current Redirects table and the end of.htaccess. - Managed hosts and CDNs. Host dashboards and CDN redirect rules apply before your origin sees the request. If the redirect appears even when the origin is down, or the response headers show the CDN's server name, check the redirect and page rules there.
Write down where you found the rule. It tends to come back during a theme change, a plugin reinstall or a migration, and website migrations are a common time for catch-all rules to be added.
What to put in place instead
Removing the catch-all is half the job. Replace it with responses that match what happened to each URL:
| Situation | Response |
|---|---|
| URL never existed or was removed with no replacement | 404, or 410 if the removal is permanent |
| Page moved, or content merged into one page | 301 to that specific page |
| Group of old pages consolidated into one guide | 301 from each to the guide (Google allows this) |
| Page temporarily unavailable | 503, optionally with a Retry-After header |
Give the 404 page real help for people: a short message, a search box and links to your main sections. That keeps visitors on the site without telling crawlers the homepage is the missing page. For individual redirects that do belong, 301, 302, 307 and 308 explains which code to choose.
Then run the invented-URL test again, both at the root and inside each main section. You want a 404 or 410 on the first response, no Location header, and your custom 404 page in the body.
Frequently asked questions
Is it ever fine to redirect a 404 to the homepage?
Only when the homepage genuinely replaces the old page, which is rare. Google's site move guide warns against sending many old URLs to one irrelevant destination such as the home page.
Does a 302 instead of a 301 avoid the problem?
No. The issue is the destination, not the redirect type. A temporary redirect to the homepage still hands crawlers a page that does not match the URL they asked for.
Will lots of 404s hurt my site after I remove the rule?
Google's documentation says 4xx responses other than 429 do not affect the site's crawl rate, and that 404s are not necessarily a problem for removed pages. Fix internal links that point to them, and redirect the ones that have a real replacement.
Why does my server still redirect after I deleted the rule?
Usually a cache. Clear the page cache plugin and the CDN cache, then test with curl rather than a browser, because browsers cache 301 redirects.
Check how a missing URL looks to crawlers
After the fix, request an invented URL with curl and confirm the first response is a 404. To see the status code, headers and readable content of a real page the way AI crawlers receive it, run the free check.
Filed under Access and robots.txt. Topics: redirects, http-status, google, wordpress