Skip to content

How to fix 404 errors on WordPress posts and pages that exist

When posts and pages that exist in WordPress answer "404 Not Found", the content is fine and its addresses are not reaching it. Saving the permalink settings again rebuilds WordPress's list of addresses. If that changes nothing, .htaccess has lost its WordPress rules.

By
WP Ministry
Published
Tested on
WordPress 7.1.3, PHP 8.3.35

In short

  • Your posts and pages are still there. This kind of 404 is about addresses, not content.
  • Look at the 404 page itself. One in your site's design came from WordPress. A plain "Not Found" came from the web server.
  • Saving the permalink settings again, with nothing changed, is the first thing to try.
  • If the home page loads and every other address fails, .htaccess is missing or the server is ignoring it.

A 404 means nothing was found at the address that was asked for. This page is about the confusing kind: the post or page is there in your dashboard, published, and its address still answers 404. The content is not the problem. The request is not reaching it.

Nothing has been deleted, and nothing below changes your content.

Check that the page is really there

If one address fails and the rest of the site works, the page is probably gone or has moved. Look for it under Posts or Pages, among the drafts and in the Trash. WordPress keeps deleted items in the Trash for 30 days, and Restore brings one back. A page that was removed on purpose needs a redirect to whatever replaced it, not a repair.

If many addresses fail at once, carry on.

Look at the 404 page you get

  • Your site's own design, with a message such as "Page not found". WordPress received the request and had no match for the address. Start with the first fix.
  • A plain page headed "Not Found" that says "The requested URL was not found on this server." The web server answered without asking WordPress. Go to the second fix.
  • A plain page that says "404 Not Found" with "nginx" under it. Go to the third fix.

If the page says "Forbidden" instead, the server is refusing the request, not failing to find it. See 403 Forbidden.

Where it goes wrong

A page request passes through each of these in turn. This one comes from the web server.

  1. Browser
  2. DNS
  3. HTTPS
  4. CDN or firewall
  5. Web server (this error comes from here)
  6. PHP
  7. WordPress
  8. Database and files

What causes it

  • WordPress's list of addresses is out of date

    Common

    WordPress keeps a saved list of which addresses lead to which content. When a plugin or theme adds a new kind of content, or changes the addresses of its own, the list can be left behind. An address that is not on it gets a 404.

    Fix: Save the permalink settings again

  • The .htaccess file is missing or has lost its WordPress rules

    Common

    On Apache and LiteSpeed, a few lines in .htaccess hand every address to WordPress. Without them the server looks for a real file at that address, finds none and answers 404 itself.

    Fix: Put the WordPress rules back in .htaccess

  • The server is not set up to pass addresses to WordPress

    Sometimes

    nginx has no .htaccess and needs the rule in its own configuration. Apache can be set to ignore .htaccess altogether. Either can be the case after a move to a new server.

    Fix: Have the server pass addresses to WordPress

How to fix it

Put the WordPress rules back in .htaccess

  • Easy
  • Back up first
  • About 5 minutes
  • Steps tested on WordPress 7.1.3

This applies to sites on Apache or LiteSpeed.

  1. Step 1: Look for .htaccess in the site's main folder

    It sits beside wp-config.php. Its name begins with a dot, so turn on "Show hidden files" in your file manager if you cannot see it. If there is one, download a copy before you change it.

  2. Step 2: Give it the WordPress rules

    If the file is missing or empty, create it with exactly this content. If it holds other rules but no # BEGIN WordPress section, add this at the end.

    .htaccess
    # 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
  3. Step 3: Reload an address that failed

    If the post appears, the rules were missing.

The block is for a site at the root of its domain. If WordPress lives in a subfolder, such as example.com/blog, two lines carry the folder's name: RewriteBase /blog/ and RewriteRule . /blog/index.php [L].

If the site answers 500 Internal Server Error after the change, the file has a line the server cannot read. Put your copy back and compare the two.

To undo it: Put your copy of the old .htaccess back.

Have the server pass addresses to WordPress

  • Advanced
  • Low risk
  • About 20 minutes

If .htaccess is right and the plain "Not Found" page stays, the server is not using it.

On nginx, the site's configuration needs this inside its location / block. On a server you run yourself, add it and reload nginx. On managed hosting, ask the host to confirm it is there.

nginx
try_files $uri $uri/ /index.php?$args;

On Apache, two things must be true: the mod_rewrite module is switched on, and the server allows .htaccess files for your site's folder, which is the AllowOverride setting. Ask the host to check both. Tell them the home page loads, that every other address answers 404, and that .htaccess holds the standard WordPress rules.

When to get help

If the permalink settings are saved, .htaccess holds the WordPress rules and posts still answer 404, the server is not passing requests to WordPress. That is set in the server's own configuration, which on most hosting only the host can change.

Common questions

Will saving the permalink settings change my addresses?

No, as long as you change nothing on the screen. Saving only rebuilds the list from the settings you already have.

Why does the home page load when nothing else does?

The home page is the folder's own index file, which the server finds without any help. Every other address exists only inside WordPress, so it depends on the rules that hand requests over.

Only one plugin's pages answer 404. Why?

Those addresses are not on WordPress's list yet. Saving the permalink settings adds them. If it happens again after each update of that plugin, report it to the plugin's author.

Can I switch to Plain permalinks instead?

As a stopgap, yes. Plain addresses, such as /?p=123, need no help from the server. But every address on the site changes, and links to the old ones still fail. Fix the cause and switch back.

More on this subject

Would you rather we fixed it?

Quick Fix is $49. One issue, one site, up to about an hour. No fix, no fee. 30-day warranty. It starts with a free diagnosis.