The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Yes, WordPress can redirect missing URLs to your homepage. But sending every 404 there is usually a poor default: a homepage seldom matches what someone expected to find, and Google warns that irrelevant redirects can be treated as soft 404s. For most sites, redirect an obsolete URL to its closest relevant replacement—or keep a useful 404 page for URLs with no replacement. If a global homepage fallback is still right for your situation, use the methods and checks below.
Decide whether a homepage redirect is right for your site
A 404 is an HTTP response saying that the requested URL was not found. WordPress can display a designed 404 template while still returning that status. A redirect is different: the server returns a 3xx response and sends the visitor to another URL. A page that looks like your homepage is not proof that a redirect occurred; check the response status and destination.
Google advises against routing unknown or nonexistent URLs to the homepage because the destination may be irrelevant and the result can be treated as a soft 404. See Google’s guidance on 404 errors and its site-move guidance. A 404 for a URL that never existed is not automatically a search problem. Broken internal links, lost pages with no replacement, and incomplete migration redirects are more actionable issues.
- A close replacement exists: Redirect the old URL to that page, usually with a permanent redirect if the change is lasting.
- There is no equivalent: Return a real 404 with useful navigation, or use 410 Gone if the content was intentionally removed and should not be replaced.
- You have a specific reason for a catch-all: A homepage fallback may make sense temporarily during a migration or for a very simple site, but map valuable known URLs individually and review the fallback rather than leaving it unquestioned.
Before changing behavior, inspect 404 logs and referrers where available. Fix internal links, correct common misspellings, and identify old URLs that still receive meaningful traffic. Redirecting everything can hide these problems rather than solve them.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
#1 Best Overall
Redirect all WordPress 404s with code
Use a site-specific plugin to keep the behavior independent of your theme. If you add the code to a theme, use a child theme’s functions.php, not the parent theme’s file. Back up the site and test on staging when possible.
add_action( 'template_redirect', function () {
if ( is_404() ) {
wp_safe_redirect( home_url( '/' ), 301 );
exit;
}
} );
template_redirectruns before WordPress renders the template.is_404()limits the behavior to requests WordPress has classified as not found.home_url( '/' )uses the site’s configured home URL rather than a hard-coded domain.wp_safe_redirect()performs a safe local redirect. WordPress documents that its redirect functions do not stop execution automatically, so the followingexit;prevents the original request from continuing to render. See the WordPress redirect reference.
The example uses 301 because it represents a permanent redirect. Use 302 or 307 for a genuinely temporary change; 307 preserves the request method more strictly than 302. A 308 is a permanent method-preserving alternative to 301. Ordinary missing-page requests are generally GET requests, so the key decision is whether the destination is appropriate and whether the change is actually permanent. Google treats permanent redirects as a canonicalization signal, not a guarantee that every ranking signal transfers identically; see Google’s redirect guidance.
This hook only applies when a request reaches WordPress and WordPress recognizes it as a 404. A CDN, web server, static-file handler, security layer, or host-level error page may answer first. A broad catch-all can also send missing images, scripts, feeds, or API requests to an HTML page, so test those paths before keeping the rule.
Prefer an exact redirect for a known obsolete URL
If one old page has a clear successor, send only that path to its replacement rather than redirecting every unknown URL:
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →add_action( 'template_redirect', function () {
$request_path = wp_parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
if ( is_404() && '/old-page/' === $request_path ) {
wp_safe_redirect( home_url( '/new-page/' ), 301 );
exit;
}
} );
Replace the example paths with your actual old and new paths. For a migration with many URLs, create a URL map and route each old address to its closest equivalent. Avoid sending unrelated pages to the homepage simply to eliminate 404 reports.
Use a plugin if you prefer a dashboard
Redirection: manage individual rules and investigate 404s
- In WordPress, go to Plugins → Add New Plugin, search for Redirection, then install and activate it.
- Open Tools → Redirection.
- Add specific old-to-new redirects where a relevant destination exists, and review 404 logs to find broken links or useful old URLs.
- If your installed version and settings provide a 404 fallback rule, configure it cautiously and test it; plugin labels and options can change between versions.
The plugin’s WordPress.org listing describes 301 rules, 404 tracking, regular expressions, query-parameter handling, import/export, Apache .htaccess and Nginx rule export, and conditional rules including 404 page type. The listing identifies it as free and says there is no premium version: Redirection on WordPress.org. It is a better fit for ongoing URL management than a bare catch-all, though a very high-volume site may choose server- or edge-level rules instead.
Dedicated plugins: simpler global behavior, fewer controls
Redirect 404 to Homepage describes a simple, settings-free 301 redirect of missing links to the homepage. That simplicity also means less control over individual mappings and less visibility into the broken URLs being redirected. Its listing’s claims about SEO benefits are product claims, not a substitute for Google’s warning about irrelevant homepage redirects.
404 to 301 advertises a global fallback to the homepage, a chosen page, or another URL, alongside 404 logging and custom rules. Check the current plugin listing and settings before relying on a particular option. Choose a global redirect plugin only if you have decided that a catch-all is appropriate; activation does not repair broken links or create relevant replacements.
Consider a helpful 404 page instead
For most sites, a useful 404 template offers visitors a way forward without pretending the missing address contains the homepage. Keep the response as 404 and include features suited to your site:
- A clear “Page not found” message.
- A link to the homepage and working site search.
- Popular content, categories, or product navigation.
- A way to report a broken link.
- The requested path, if showing it helps visitors identify a typo.
Verify the response, not just what the browser displays
- Open a deliberately nonexistent page, such as
https://example.com/this-page-should-not-exist/. - Confirm the browser reaches the intended destination, then inspect the HTTP status and
Locationheader. A permanent redirect should show a 3xx response and a location pointing to the homepage; the final response should be the homepage’s normal success response. - Check more than one type of request: a missing post, page, image or other asset,
/wp-admin/,/wp-json/, a feed, a URL with query parameters, and a logged-in administrator session. - Look for unexpected redirect chains or loops. If results appear stale, clear the relevant page, object, CDN, and browser caches.
From a terminal, inspect the first response with:
curl -I https://example.com/this-page-should-not-exist/
To follow the full chain and see the final response, use:
curl -IL https://example.com/this-page-should-not-exist/
WordPress’s canonical redirect behavior may attempt to correct or guess a URL before your custom behavior is the only redirect in play. Inspect the entire chain; see the WordPress canonical redirect reference.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshoot redirects that fail or loop
The redirect never happens
- Confirm the snippet or plugin is active and the code has no syntax error.
- Verify the request actually becomes a WordPress 404. A missing static file or a request intercepted upstream may never reach the hook.
- Check whether a cache, server rule, CDN, security plugin, or another redirect plugin handles the request first.
- For multisite, confirm the code is active in the intended network or site context.
The browser shows the old page or a loop
A missing exit; can let the original request continue after the redirect call. A loop may arise if the homepage itself is misclassified as a 404, the target is wrong, HTTP and HTTPS rules conflict, WordPress Address and Site Address settings disagree, or CDN and origin rules send visitors in opposite directions.
Free tools Windows power users keep installed
One-click scans. No signup required.
Best Value
If you are locked out, disable the snippet through hosting file access or the database/plugin screen; if a plugin caused the issue and the dashboard is unavailable, temporarily rename its directory through hosting file access. Remove or correct server-level rules, purge caches, test the homepage directly, and only then re-enable a corrected redirect.
Only some missing URLs are redirected
A WordPress hook cannot control a response generated earlier by a CDN, web server, hosting error document, static-file handler, or firewall. Check the relevant access and error logs, then adjust the rule at the layer that is actually serving that request. Be especially careful not to funnel REST endpoints, feeds, scripts, or missing media into an HTML homepage.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




