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 Broken Permalinks in WordPress

Short answer

To fix broken permalinks in WordPress, open Settings, then Permalinks, and click Save Changes without changing the structure. That rebuilds the rewrite rules WordPress uses to match each URL to a post or page. If posts still return a 404 error, check the .htaccess file on Apache or the try_files rule on Nginx.

Key takeaways

  • Resaving Settings then Permalinks rebuilds WordPress rewrite rules and is the first fix to try.
  • A home page that loads while posts return 404 points to a rewrite or server routing fault.
  • On Apache, WordPress needs a writable .htaccess file and the mod_rewrite module to use pretty permalinks.
  • Nginx does not read .htaccess, so its server block needs try_files $uri $uri/ /index.php?$args;
  • A custom post type that 404s often needs its plugin deactivated and reactivated, then a permalink resave.
  • Changing the permalink structure changes every post URL, so keep the structure the same while you fix it.

A broken permalink is a post or page URL that returns a 404 error even though the content still exists in WordPress.

A permalink is the permanent URL of a post, page, category or archive, as WordPress.org explains in its Customize permalinks guide.

Pretty permalinks use readable words, such as example.com/2012/post-name/, while the Plain structure uses a query string, such as example.com/?p=N, where N is the post ID.

WordPress.org lists 6 permalink options: Plain, Day and name, Month and name, Numeric, Post name and Custom Structure.

The Plain structure is the default, and WordPress.org says it works on all server environments but is not user friendly and not made for search engines.

Why do posts return 404 while the home page still loads?

Posts return 404 while the home page loads when the server does not pass pretty URLs to WordPress, so WordPress never gets a chance to find the post.

No file exists at a pretty URL such as /my-post/, so the server must send that request to index.php for WordPress to match it.

The home page still loads because it is index.php itself, so it does not need that routing step.

This pattern points to missing or ignored rewrite rules, not to deleted content.

SymptomLikely causeFirst fix
Every post and page 404s, home page worksRewrite rules missing or not appliedResave permalinks
Only one URL 404sWrong slug, draft, or deleted postCheck the post status and slug
Only a custom post type 404sPlugin rules not registeredReactivate the plugin, then resave permalinks
URLs work with Plain but not Post nameServer rewrite support missingCheck .htaccess on Apache or try_files on Nginx

If only one URL fails, read the guide to fixing 404 errors on posts before you change any server file.

Resave your permalinks to rebuild the rewrite rules, and do it before you edit any server file.

WordPress keeps its rewrite rules in the database, and the Developer Handbook says they need a refresh from Settings then Permalinks before changes take effect, as stated in its Rewrite API page.

Follow these steps in order:

  1. Back up the site first, using the steps in the guide to backing up WordPress.
  2. Open the WordPress dashboard and go to Settings, then Permalinks.
  3. Leave the selected structure exactly as it is.
  4. Click Save Changes at the bottom of the page.
  5. Open a post and a page in a private browser window and check that each one loads.

Do not change the structure during this step, because changing it changes every post URL on the site.

WordPress.org says a custom structure must end with either %post_id% or %postname% so WordPress can target each post, as of November 2026.

If you have WP-CLI access, wp rewrite flush gives the same result from the command line, as shown in the WP-CLI rewrite command docs.

What should you check in .htaccess on Apache?

Check that the .htaccess file exists in the WordPress root folder, that WordPress can write to it, and that Apache reads it.

On Apache, saving permalinks tries to write the rewrite rules into .htaccess, so a missing or unwritable file stops the fix.

Follow these steps:

  1. Download a copy of .htaccess from the folder that holds wp-config.php, so you can restore it.
  2. Look for the WordPress block in the file and check that it has not been damaged by other rules.
  3. If the file is missing, save permalinks again and let WordPress create a fresh one.
  4. If WordPress shows a message that it cannot update .htaccess, copy the rules it shows on the Permalinks screen into the file by hand.
  5. Ask your host to confirm that the mod_rewrite module is loaded for the site.

Apache docs say .htaccess rewrite rules are ignored unless the server allows them, as explained in the Apache per-directory rewrites guide.

That guide says the server needs AllowOverride FileInfo or AllowOverride All, plus FollowSymLinks or SymLinksIfOwnerMatch, for the rules to run.

A damaged .htaccess file can also cause a 500 error, so restore your copy at once if the whole site stops loading, as covered in the guide to fixing the 500 error.

Fix permalinks on Nginx by adding the WordPress try_files rule to the server block, because Nginx does not read .htaccess at all.

Learn WordPress says Nginx has no file like .htaccess, so the routing lives in the server block, as stated in its permalinks lesson.

Use this rule in the location / block:

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

Nginx checks each item in order, as its try_files docs explain: first a matching file, then a matching folder, then the last item as a fallback.

The fallback sends the request to index.php with the query string kept, so WordPress can match the URL.

If the last item is =404 instead, Nginx returns its own 404 before WordPress sees the request, so change that line.

After editing the server block, test the config and reload Nginx, then resave permalinks in WordPress and open a post to check it.

Why do only some posts, categories or custom post types break?

Only some URLs break when their own rewrite rules are missing, while the main post rules still work.

A custom post type is a content type added by a plugin or theme, such as products or events, and its rules must be registered before WordPress can match its URLs.

Deactivate the plugin that creates the post type, reactivate it, then go to Settings, then Permalinks and click Save Changes.

The Developer Handbook says flush_rewrite_rules() removes the old rules and recreates them, as stated in its flush_rewrite_rules reference.

That function defaults to a hard flush, which also updates .htaccess, and the docs warn that it is an expensive step, so it should run only when needed.

For categories, WordPress.org says the default category base is category and the default tag base is tag, and you cannot remove them from URLs altogether.

If a post has more than one category, WordPress.org says only one category shows in the permalink, and it is picked alphabetically, as of November 2026.

A slug clash can also break one URL, such as a page and a post with the same slug, so change one slug and resave permalinks.

A cache problem shows an old page, while a permalink problem shows a 404 error, so the error message tells you which one you have.

If the post loads with the Plain structure (?p=123) but not with Post name, the fault is in the rewrite rules, not the cache.

If the post loads after you clear the cache but fails again later, check the cache settings before you edit server files.

Cloudflare docs say its WordPress plugin can purge the cached copy of a post, page or attachment when that item is added, edited or deleted, as stated in its Automatic Cache Management page.

That page also says switching or changing a theme clears the cache too.

To test, open the failing URL in a private window, then purge the cache and try again, using the steps in the guide to setting up Cloudflare for WordPress.

If the same URL still 404s in a private window after a purge, treat it as a permalink fault and work through the resave and server steps above.

When should you contact your host?

Contact your host when the fix needs a server setting you cannot change, such as the rewrite module or the Nginx server block.

WordPress.org says your host should have set up the web server so Pretty and Almost Pretty permalinks work, and you should contact your host if they do not, as stated in its Customize permalinks guide.

Send the host these 4 facts: the site runs Apache or Nginx, the home page loads, every inner URL returns 404, and resaving permalinks did not fix it.

Ask the host to confirm 3 items: mod_rewrite is loaded on Apache, AllowOverride permits .htaccess rules, or the Nginx try_files rule sends requests to index.php.

If the site moved to a new host just before the fault started, say so, because the new server may use a different setup, as covered in the guide to broken links after a migration.

Do not ask the host to change your permalink structure, because that changes every URL and needs redirects first.

What mistakes should you avoid?

Avoid changing the permalink structure as a fix, because that changes every URL on the site and breaks links from search engines and other sites.

Do not delete .htaccess without a copy, because a bad edit can take the whole site down.

Do not add rewrite rules copied from another site, because the rules shown on your own Permalinks screen match your own folder and setup.

Do not keep resaving permalinks again and again when the first save did not work, because the fault is then in the server setup, not in WordPress.

Do not edit the Nginx config on a managed host without asking the host first, because the host may overwrite your change or use a different config file.

Check one change at a time, then open a post, a page and a category archive to confirm each one loads before you move on.

Frequently asked questions

Why does my home page work but all my posts show a 404 error?

The home page is index.php itself, so it loads without rewrite rules. Posts use pretty URLs with no matching file on disk, so the server must send those requests to index.php. When that routing fails, WordPress never sees the request and the server returns a 404 error. Resaving permalinks is the first fix, then check the server rewrite setup.

Will resaving permalinks change my post URLs?

No, if you leave the selected structure unchanged and only click Save Changes. That step rebuilds the rewrite rules without changing any URL. Changing the structure itself, such as switching from Post name to Day and name, changes every post URL. Only change the structure if you mean to, and set up redirects first.

What if WordPress says it cannot update my .htaccess file?

WordPress shows the rules it wants to write at the bottom of the Permalinks screen when it cannot write the file. Copy those exact rules into the .htaccess file in the WordPress root folder by hand, using FTP or your host file manager. Keep a copy of the old file first. Then save permalinks again and check a post.

Do I need to fix .htaccess on Nginx hosting?

No. Nginx does not read .htaccess files, so editing one will not help. The routing must be in the Nginx server block, with a try_files rule that sends unmatched requests to index.php. If you use managed Nginx hosting, ask your host to check that rule. Resaving permalinks still helps, because it refreshes the rules inside WordPress.

Why does only one custom post type return a 404 error?

That post type may have been registered after the rewrite rules were last built, so WordPress has no rule for its URLs. Deactivate and reactivate the plugin that creates the post type, then resave permalinks. If it still fails, check for a slug clash with a page or another post type, and check that the item is published and not in draft.

Sources

  1. Customize permalinks WordPress.org
  2. Rewrite API WordPress Developer Resources
  3. wp rewrite command WordPress Developer Resources
  4. flush_rewrite_rules() WordPress Developer Resources
  5. Per-directory Rewrites Apache HTTP Server
  6. try_files directive NGINX
  7. Permalinks, rewriting URLs on Apache and Nginx Learn WordPress
  8. Cloudflare WordPress Plugin Automatic Cache Management Cloudflare

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