WordPress throws 404 errors more easily than it seems: a permalink change, a plugin that gets deactivated or a product deleted in WooCommerce is enough to leave dozens of broken URLs behind. These are the most frequent causes and how to solve each one.
Every post returns 404 at once
If the home page works but every post or page returns 404, it is almost always the .htaccess file or the rewrite rules. The quick fix:
- Go to Settings → Permalinks.
- Without changing anything, click Save Changes. WordPress rebuilds the rules.
If it still fails, check that the .htaccess at the root has the standard block:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
You changed the permalink structure
If you moved from /?p=123 or /2024/05/title/ to /title/, the old URLs that live in Google and on other sites stop existing. WordPress redirects some of them automatically, but not all. Use a redirect plugin (such as Redirection) to create a 301 rule with a regular expression, for example:
Source: ^/\d{4}/\d{2}/(.*)$
Target: /$1
You deleted posts, pages or products
- If there is equivalent content, 301 the old URL to that content.
- In WooCommerce, for a discontinued product it is better to redirect to its category or to a similar product, not to the shop as a whole.
- If there is no replacement, leave the 404 (or better, a 410) and remove the internal links pointing there.
Images and files that return 404
This happens after migrating the site or changing domain: posts still point to http://old-domain.com/wp-content/uploads/.... Fix it with a search and replace in the database (plugins such as Better Search Replace). Always take a backup first.
How to find the 404s that already exist
- Search Console → Pages → Not found (404).
- The Redirection plugin records the 404s that get real visits, with the number of hits.
- A crawl of the site to find broken internal links before Google finds them.
A 404 page that does not lose the visitor
Even after fixing them, there will always be some 404. Make sure your 404 template has a search box and links to the main sections and the most visited content: that way anyone landing on a page that does not exist keeps browsing instead of leaving.
If you want to see the state of your site without installing anything, scan your site free with CLIC404: it reviews broken links, security headers and basic SEO in a single report.
Want to know how your site is doing right now?
Scan your site for free: broken links, security headers and basic SEO in a single report.
Scan my site free