Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared Managed Cloud India
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Best lists Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Troubleshooting · Troubleshooting

How to Fix 404 Errors on Posts and Pages in WordPress

Short answer

A 404 error on a WordPress post or page usually means the rewrite rules that match URLs to content are stale or missing. Open Settings, then Permalinks, and click Save Changes to rebuild them. If the error stays, repair the .htaccess file, check the slug and Trash status, or add a 301 redirect to the new URL.

Key takeaways

  • Saving permalinks at Settings, then Permalinks, rebuilds the rewrite rules that match post and page URLs to content.
  • On Apache, a missing or broken .htaccess file makes every post and page return 404 while the homepage still loads.
  • Nginx does not read .htaccess, so its 404 fix needs the try_files line in the server block, which your host controls.
  • A changed slug or a trashed post causes a 404 on one URL only, and restoring the item or fixing the slug brings it back.
  • When content has moved for good, add a 301 redirect to the closest live page instead of leaving the old URL as a 404.
  • Trashed posts and pages stay in the Trash for 30 days by default before WordPress deletes them for good.

What does a 404 error mean on a WordPress post or page?

A 404 error means the server could not find a page at the address you requested, even though the post or page may still exist in WordPress.

A 404 is an HTTP status code, and it tells the browser that nothing matches that URL. WordPress.org calls a permalink the permanent URL of a post or page, so a 404 on that URL means the link between the address and the content has broken.

The page is often still in your dashboard under “Posts → All Posts” or “Pages → All Pages”. When it is there but the public URL shows 404, the fault is usually in the rewrite rules or the address.

Why do posts 404 while the homepage still works?

Posts 404 while the homepage works because the homepage loads as index.php directly, while post URLs need rewrite rules to reach WordPress.

WordPress stores rewrite rules in the database, and on Apache it also writes them to the .htaccess file. When those rules are missing or stale, the server looks for a real folder at that address, finds none, and returns 404.

This pattern often follows a site move, a host change, or a permalink change. WordPress.org notes that 404 errors with pretty permalinks can appear after a site migration or server move.

A plain server 404 points to the web server, while your theme's styled 404 page means WordPress received the request but found no matching content.

Open “Settings → Permalinks” and click “Save Changes” to rebuild the rewrite rules that match URLs to posts and pages.

WordPress.org states that visiting the Permalinks screen triggers a flush of rewrite rules, so opening the screen alone starts the rebuild.

Follow these steps in order:

  1. Log in to wp-admin and go to “Settings → Permalinks”.
  2. Leave the structure as it is unless you plan to change it.
  3. Click “Save Changes” at the bottom of the screen.
  4. Reload a post or page that showed 404.

WordPress shows “Permalink structure updated.” when the .htaccess file is writable, according to the Settings Permalinks screen on WordPress.org. If the file is not writable, the screen says “You should update your .htaccess now.” and shows the rules to add by hand.

If you use WP-CLI, the wp rewrite flush command does the same job from the command line. The --hard flag also updates .htaccess rules, and the WP-CLI docs state that it works only on single site installs.

How do you repair a missing or broken .htaccess file?

Replace the WordPress block in your site root .htaccess file with the default block, keeping your own rules outside the WordPress markers.

On Apache, the .htaccess file passes each address to WordPress. WordPress.org's common errors guide gives this default block for a site at the domain root.

WordPress wraps these lines in a check that the mod_rewrite module is loaded. Apache's own mod_rewrite docs describe it as a rule-based engine that rewrites requested URLs on the fly.

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

The two RewriteCond lines send the request to index.php only when it is not a real file and not a real directory. The Learn WordPress lesson on permalinks shows the same block, with one extra line for the authorization header.

Before you edit the file, download a copy of it. A backup lets you undo the change fast, and our guide to restoring a backup with UpdraftPlus explains how to recover a site from a backup.

Use FTP or your host file manager to open the file where WordPress is installed. Files that start with a dot are hidden on most servers, so turn on hidden files in your FTP client first.

SymptomLikely causeFix to try first
All posts and pages 404, homepage worksRewrite rules missing or staleSave permalinks again
“You should update your .htaccess now.”File is not writablePaste the default block by hand
404 after a plugin changePlugin added a bad ruleRemove rules outside the WordPress markers, then save permalinks
404 on one new post type onlyRewrite rules not flushed for itSave permalinks, then check for a name clash

WordPress rewrites everything between # BEGIN WordPress and # END WordPress each time you save permalinks, so put your own rules above those markers.

If the error started after a move to a new host, ask the host to check that mod_rewrite is enabled. WordPress.org states that 404 errors with pretty permalinks can mean mod_rewrite is not enabled in Apache.

How do you fix 404 errors on nginx?

On nginx, ask your host to check that the server block sends unmatched URLs to index.php, because nginx does not read .htaccess at all.

The Learn WordPress lesson on permalinks states that nginx does not support an .htaccess-style file, so the rewrite config lives in the server block. The standard location block it shows is:

location / {
    try_files $uri $uri/ /index.php?$args;
}

This line tells nginx to serve a real file or folder when one exists, and to pass anything else to index.php with the query string. The NGINX blog gives the same try_files line in its WordPress performance guide.

You cannot fix an nginx 404 by editing .htaccess. Saving permalinks still rebuilds the rules in the WordPress database, but the server-side step needs your host, since most managed hosts control the server block.

Send your host the exact URL that 404s and the date the error started, so they can check the try_files line.

How do you fix a 404 on one post or page only?

Check that single post or page first, because a site-wide fix will not help when only one address is wrong.

A single 404 usually means the slug changed, the address was typed wrong, or the item was moved. The slug is the last part of the URL, such as about-us in example.com/about-us/.

Follow these steps:

  1. Go to “Posts → All Posts” or “Pages → All Pages”.
  2. Hover over the title and click “Quick Edit”.
  3. Read the “Slug” field and fix it if it changed, then click “Update”.
  4. Reload the exact URL, including the trailing slash.

WordPress.org states that a post slug comes from the title and is cleaned up for the URL, so a title edit can change the address. If you changed a published post slug, WordPress redirects the old post address to the new one, but it does not do this for pages.

A name clash can also cause a single 404. WordPress.org advises checking that no custom post type and single page share the same name, and renaming the page, including its slug, when they do.

How do you restore a trashed post or page that returns 404?

Open the Trash view for posts or pages, hover over the item, and click “Restore” to bring it back.

A trashed post or page is hidden from visitors, so its URL returns 404 until you restore it. The WordPress Codex states that items stay in the Trash for 30 days by default before they are permanently deleted, so check quickly.

Follow these steps:

  1. Go to “Posts → All Posts” or “Pages → All Pages”.
  2. Click the “Trash” link near the top of the screen.
  3. Hover over the item and click “Restore”.
  4. Reload the URL to confirm the page loads again.

For several items at once, tick their checkboxes, choose “Restore” from the bulk actions menu, and click “Apply”. The Codex notes that you can bulk-restore this way from the Trash view.

If the item is no longer in Trash, it was permanently deleted after the 30-day window. In that case, restore it from a backup instead of recreating the page, since a fresh page may get a different slug.

How do you redirect an old URL instead of leaving a 404?

Add a 301 redirect from the old URL to the closest live page when the content moved or its slug changed for good.

A 301 redirect tells browsers and search engines that the move is permanent. Google Search Central advises returning a 301 (permanent redirect) when a page has moved or has a clear replacement, and returning a 404 (not found) or 410 (gone) code when the page is gone with no replacement.

WordPress has no built-in redirect screen, so use a redirect plugin. The free Redirection plugin on WordPress.org manages 301 redirects, tracks 404 errors, and can watch for permalink changes and create a redirect to the new URL. Its page states that it works with PHP 7.4 to 8.5 as of November 2026.

To add one redirect:

  1. Install and activate Redirection, then open “Tools → Redirection”.
  2. Enter the old URL in the source field and the new URL in the target field.
  3. Leave the type as 301 and save it.
  4. Open the old URL in a private browser window and confirm it lands on the new page.

Do not redirect every old URL to the homepage. Google warns that sending many old URLs to one unrelated page can confuse visitors, and its crawling errors guide lists that as a cause of soft 404 errors.

If you already use an SEO plugin, check its redirect tool first. Our guide to using Yoast SEO redirects covers the redirect screen in Yoast SEO.

Moving a site is another common trigger for broken URLs, so read our guide to moving a WordPress site without losing SEO before a migration.

How do you check that the 404 is really fixed?

Reload the exact URL in a private window, then check it again after clearing any cache, because a cached error page can hide a fix.

Start with the URL that failed, not a similar one. A private window skips your browser cache, and clearing your cache plugin or CDN cache removes the server-side copy of the error page.

Then check these 3 points:

  • The post or page loads with its full content, not a 404 template.
  • Links from your menu and from other posts reach the same URL.
  • The URL works without ?p=123 added to it, unless you use the Plain structure.

WordPress offers 6 permalink structures on the Settings screen: Plain, Day and name, Month and name, Numeric, Post name, and Custom structure. The Plain example in the WordPress docs is http://www.sample.com/?p=123, while the Post name example is http://www.sample.com/sample-post.

For search results, check Google Search Console. Google Search Central states that a soft 404 is a page that tells the user it does not exist while also returning a 200 (success) status code, and that such pages are excluded from Search.

If the URL still 404s after saving permalinks, fixing .htaccess, and clearing cache, contact your host. Ask them to confirm mod_rewrite on Apache or the try_files line on nginx.

Our guide on why a WordPress site is not showing on Google covers the search side of a page that stays hidden after the fix.

What mistakes should you avoid?

Do not change your permalink structure to fix a 404, because that change breaks every old URL on your site at once.

Saving the same structure rebuilds the rules without changing addresses. Changing the structure gives every post a new URL and creates a fresh set of 404s.

Avoid these 4 mistakes:

  • Editing .htaccess without a backup copy first.
  • Adding your own rules between the # BEGIN WordPress and # END WordPress markers, where WordPress will overwrite them.
  • Redirecting all dead URLs to the homepage instead of to the closest live page.
  • Deleting a trashed post to “fix” its 404, when restoring it would bring the page back.

The WordPress docs also note that the default Plain structure works on all server environments, so switching to Plain for a short check can tell you whether the content still exists. If the Plain URL loads, the post is fine and the rewrite rules are the fault.

Frequently asked questions

Why do all my WordPress posts show 404 but the homepage works?

The homepage loads as index.php directly, while post URLs need rewrite rules to reach WordPress. When those rules are missing, stale, or ignored by the server, Apache looks for a real folder at that address and returns 404. Saving permalinks rebuilds the rules, and repairing the .htaccess file fixes the server side on Apache.

Will saving permalinks change my post URLs?

No, saving the same permalink structure does not change your URLs. It only rebuilds the rewrite rules that match those URLs to posts and pages. Changing the structure itself, such as moving from Post name to Day and name, does give every post a new URL, so only save the structure you already use unless you plan a full change with redirects.

Can I fix a 404 error on nginx by editing .htaccess?

No, nginx does not read .htaccess at all, so editing that file will not help. The rewrite config lives in the nginx server block, usually as a try_files line that sends unmatched URLs to index.php. Most managed hosts control that file, so send your host the failing URL and ask them to check it.

How long do I have to restore a trashed post that returns 404?

You have 30 days by default. WordPress keeps trashed posts and pages in the Trash for 30 days before deleting them for good. Open Posts, then All Posts, click Trash, hover over the item, and click Restore. After the 30-day window, you need a backup to bring the page back.

Should I redirect a deleted page to my homepage?

No, redirecting every dead URL to the homepage confuses visitors and can create soft 404 errors in search results. Redirect each old URL to the closest live page with similar content. If no page replaces the deleted one, leave it as a proper 404 or 410 response so search engines know the page is gone.

Do 404 errors hurt the rest of my site in search results?

A few 404 errors on URLs that no longer exist do not hurt your other pages. Google treats 404 as a normal part of the web and says the fact that some URLs return 404 does not affect how your other URLs perform. The problem to fix is a 404 on a live post or page, or a soft 404 where the page claims to be missing but returns a 200 code.

Sources

  1. Common WordPress errors WordPress.org
  2. Settings Permalinks screen WordPress.org
  3. Rewrite Developer.WordPress.org
  4. Permalinks, rewriting urls on Apache and Nginx Learn WordPress
  5. Troubleshoot Google Search crawling errors Google Search Central
  6. 9 Tips for Improving WordPress Performance NGINX Blog
  7. Apache Module mod_rewrite Apache HTTP Server

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

WPLegible editors

Researched from the primary sources listed above and checked against our editorial rules. About the site · How we test