Skip to content

WordPress 404 error on pages: permalinks and redirects

· The AYT team · 5 min read

Man typing on a laptop at a wooden table, with a phone and notebook beside it

A 404 (Not Found) error means the server is working, but there is no page at the requested address. In WordPress, how many pages return it matters. If every page except the home page returns 404, the permalink rules are missing or broken, and you fix them from Settings → Permalinks. If only a few addresses return 404, those pages were moved, renamed or deleted, and the fix is a 301 redirect to the new address.

Case 1: every page returns 404 except the home page

The home page opens, but every post, page and category returns 404. The cause: the web server isn't passing addresses like /about-us/ to WordPress, because the rewrite rules are missing. It often happens after a move to another server, after changing the permalink structure, or after a plugin edited .htaccess.

The steps, simplest first:

  1. In wp-admin, go to Settings → Permalinks and click Save Changes without changing anything. WordPress regenerates its rules and, on Apache, tries to rewrite .htaccess.
  2. On Apache, check that the site's folder has a .htaccess file. It's a hidden file, so it's easily lost in an FTP copy. The default content for a WordPress site installed at the domain root:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
  1. On nginx, .htaccess doesn't matter. The site's configuration needs the rule that sends everything that isn't a real file or folder to WordPress:
location / {
    try_files $uri $uri/ /index.php?$args;
}

On shared hosting, your host writes the nginx configuration. If the rule is missing, contact support. There's more on the differences between the two servers in the guide to .htaccess on nginx.

Case 2: one particular page returns 404

The other pages work; only one or a few don't. Check, in this order:

  • the page is in the trash, a draft, scheduled or private (in wp-admin under Pages or Posts, check the "Trash" and "Drafts" filters);
  • the slug changed. For posts, WordPress usually remembers the old slug and redirects on its own; for pages it doesn't;
  • the category or tag base changed in Settings → Permalinks, so the old addresses start differently;
  • a translation, membership or shop plugin changed the structure of its own addresses.

If you moved the page on purpose, add a 301 redirect from the old address to the new one. The steps are in the guide to 301 redirects in WordPress.

Case 3: images and files return 404

The page opens, but the images are missing. Usually the wp-content/uploads folder wasn't fully copied during a move, or the addresses in the database still point to the old domain or to http://. Check in the File Manager that the file exists at the path in the address. If the addresses are wrong, replace them in the database with a search and replace tool that handles serialized data, as when moving WordPress to a new domain.

How to find the 404s you don't see

Visitors don't report missing pages; they just leave. Find them yourself:

  • in Google Search Console, under Indexing → Pages, the reason "Not found (404)" lists the addresses Google tried;
  • the Redirection plugin keeps a log of 404 errors on the site and lets you create the redirect straight from the list;
  • the server's access log shows every request with a 404 code, including those coming from links on other sites.

What to do with each 404

  • The page exists at another address: 301 redirect to it.
  • There's a page close in subject (a product replaced by a new model, an updated article): 301 redirect to that.
  • There's no equivalent: leave the 404 (or a 410, if you removed it for good). That's a correct answer.

Don't send every 404 to the home page. Visitors don't find what they were looking for, and Google often treats such redirects as "soft 404s", which means it still counts them as missing pages.

The site's 404 page

A good 404 page says clearly that the address doesn't exist and offers a search box and a few useful links (the home page, main categories, contact). Most themes have a 404.php template or, with block themes, a 404 template you can edit under Appearance → Editor. After any change, check that the page still answers with a 404 code, not 200: otherwise Google may index it as a normal page.

Frequently asked questions

Do 404 errors hurt the site's SEO?

Google doesn't index addresses that return 404, and indexed ones drop out over time. That's normal for deleted pages. You do lose the value of links that pointed to that page, which is why pages with incoming links deserve a 301 redirect.

After a move, every page returns 404. Why?

Almost always case 1: .htaccess wasn't copied (on Apache) or the new server lacks the WordPress rules (on nginx). Save the permalinks and check the server's rules.

On AYT hosting

On AYT the web server is nginx, and the WordPress permalink rules are already in each site's configuration, so you don't need .htaccess (it isn't read anyway). You add 301 or 302 redirects for moved pages from the panel's Redirects page. If you are coming from another host, the move is free on paid plans.

The panel's Redirects page with a 301 redirect from an old address

More articles

All articles