Fix 404 errors by refreshing permalinks

  • permalinks
  • rewrite-rules
  • troubleshooting
  • site-editing

Updated

If pages that should exist return a 404 error, go to Settings → Permalinks and click Save Changes without changing anything. That refreshes your permalinks and usually fixes it. WordPress keeps an internal list that matches each URL to its content. Installing a plugin that adds new content types (events, people, documents), changing the site's URL pattern, or moving the site can leave that list out of date. Saving the permalink settings rebuilds it.

This is different from changing one page's address. For that, see Change a page's URL (permalink) in WordPress.

When to refresh

  • Event, portfolio, or other plugin pages return a 404 after you activate the plugin.
  • URLs stopped working after a migration or domain change.
  • A plugin tells you to "flush permalinks" or visit Settings → Permalinks.

There's no need to do this on a schedule. Do it when something breaks.

Refresh permalinks

  1. Go to Settings → Permalinks.
  2. Leave the structure as it is. Most Dirigible sites use Post name.
  3. Click Save Changes.

Saving without changes is enough. Retest the URLs that were failing.

If URLs still return 404

  • Confirm the page or post is published and the slug is what you expect. Private pages show a 404 to anyone who isn't logged in.
  • Clear your caching plugin or CDN cache, then try again. A cached 404 can outlast the fix; see Fix WordPress changes not showing on your site.
  • For old URLs that have moved on purpose, add a redirect.
  • If every URL except the homepage 404s after saving, your host may be blocking WordPress from updating its server settings. Contact hosting support. The next section explains what to ask for.

Every page except the homepage 404s

This usually means the web server isn't passing addresses to WordPress at all.

  • Apache servers read a file called .htaccess in the site's main folder. WordPress keeps its rules there, between # BEGIN WordPress and # END WordPress, and rewrites them when you save Settings → Permalinks. If it can't write the file, the screen says You should update your .htaccess file now. and shows the rules in a Rewrite rules: box at the bottom. Copy them into .htaccess, or send them to your host.
  • Nginx servers don't use .htaccess. WordPress can't change their settings, so the host has to add WordPress's rule to the server configuration.

If you're not sure which your host uses, send them the failing URL and ask them to check the permalink rules.

A page and another section share an address

If a page and a section of the site use the same slug, WordPress can only show one of them. For example, a page called Events at /events/ and an events plugin that also lists events at /events/. One of them stops loading or shows the wrong content. Change the page's slug (see Change a page's URL), or change the section's address in its settings. The same goes for a Category base or Tag base set under Settings → Permalinks that matches a page's slug.

Changing the URL pattern

Switching the structure under Settings → Permalinks on a live site changes every post URL and breaks existing links. If you must switch, plan redirects first.

If your site runs on Dirigible

When you click Publish in the Customizer, Dirigible refreshes permalinks on the next page load. Changing a URL setting there, such as the address of your events or portfolio pages, doesn't need a trip to Settings → Permalinks.

Built by Dirigible Studio. Get in touch