Skip to content

404 error on pages: setting permalinks in WordPress

Easy 10 min Updated:

Quick answer

A 404 error on existing pages is most often caused by incorrect permalink settings or outdated .htaccess rules. Go to Settings > Permalinks and click "Save Changes" to refresh the rules, then check .htaccess and the link structure.

How to recognize the problem

  • Pages that exist in the admin return 404 Not Found
  • The homepage works, but internal pages do not
  • Individual post links show a 404 error
  • After changing the permalink structure, old addresses stop working
  • 404 appears only on some pages, depending on settings

Most common causes

Outdated rules in the .htaccess file

WordPress uses .htaccess to redirect pretty links. If the rules are not updated, the server does not know how to handle the request and returns 404.

Changed permalink structure

If the structure was changed without 301 redirects, old addresses may return 404. The default structure (/?p=123) by itself should not cause 404 on existing pages.

mod_rewrite module not enabled

The Apache server must have the mod_rewrite module enabled. Without it, pretty links will not work and will return 404.

Conflict with caching or security plugins

Some plugins modify .htaccess or cache redirect rules, which can lead to 404 errors on existing pages.

Domain change or site migration

After moving to a new domain or server, the database may contain old paths, and .htaccess is not updated automatically.

Step-by-step fix

  1. 1

    Check that the page actually exists

    In the admin, open Pages > All Pages and make sure the page is not in the trash and that its status is "Published". If the page is in the trash, restore it from the trash and try opening it again.

  2. 2

    Reset permalinks

    Go to Settings > Permalinks. Do not change the structure, just click the Save Changes button. WordPress will regenerate the .htaccess rules, if the server allows writing, and refresh the routes.

  3. 3

    Check the .htaccess file

    On an Apache or LiteSpeed server, access the site via FTP or the file manager in your hosting panel. Make a backup of the file before making changes. Open .htaccess in the root of the WordPress installation and check whether it contains the WordPress rules block. If the file does not exist or does not contain the WordPress rules block, do not delete it. If it exists, rename it to .htaccess.bak, then save permalinks again so WordPress tries to regenerate it. If you have custom rules, restore them from the backup after checking. If the file is not regenerated, restore the backup and contact hosting support.

  4. 4

    Temporarily disable plugins

    Deactivate all plugins except essential ones, then save permalinks again. Make a backup of the site beforehand. If the error disappears, activate plugins one by one to find the culprit. Pay attention to caching, security and redirect plugins.

  5. 5

    Check whether mod_rewrite is enabled

    Contact hosting support and ask whether mod_rewrite is enabled. On Apache servers this is necessary for pretty links to work. If you use Nginx, rules are set differently and this is usually done by the server administrator or hosting support.

  6. 6

    Temporarily change the link structure

    If nothing helps, in Settings > Permalinks temporarily select another structure, for example Post name, click Save Changes, then select the desired structure again and save. Make a backup of the database and site beforehand because changing the structure changes addresses and can affect SEO. This will check whether the problem is in the link structure itself.

  7. 7

    Check whether the site is in a subdirectory

    If WordPress is installed in a subfolder (e.g. /blog/), in Settings > General check that WordPress Address (URL) and Site Address (URL) are entered correctly. An incorrect URL can cause 404 on all pages except the homepage.

  8. 8

    Clear the cache

    Clear the caching plugin cache, browser cache and server-level cache (via the hosting panel or with hosting support). Then reopen the page with a forced refresh without cache (Ctrl+F5, on macOS Cmd+Shift+R).

If nothing helps: checking the database and permalinks

If all steps have been tried and 404 still appears, the problem may be in the database. Check the options table (by default wp_options) and the values siteurl, home and permalink_structure. Make a backup of the database before making changes. If you do not know how to access the database, contact hosting support. Also, check whether the site was migrated from another domain and whether old links remained in the content. A search and replace tool in the database (e.g. Better Search Replace) can help, but use it only if you have a fresh backup. For advanced changes to .htaccess rules or Nginx configuration, consult the server administrator.

How to prevent it

  • Regularly back up the database and files before changing permalinks
  • Avoid changing the permalink structure unnecessarily
  • Use reliable caching and security plugins
  • Check the .htaccess file after site migration

When to call a professional

If you are not sure how to access the .htaccess file or database, or if the error persists after all steps, contact IT support to avoid additional damage to the site.

Website development · Fast, SEO-ready, multilingual websites

FAQ

Why do my pages return 404 when they are published?

The most common cause is an outdated .htaccess file or an incorrect permalink structure. Resetting permalinks in the settings often solves the problem.

Will I lose SEO if I change permalinks?

Yes, old addresses may stop working and lose ranking. That is why it is best not to change the structure unnecessarily, and if you must, set up 301 redirects.

How do I know if the problem is in a plugin?

Temporarily deactivate all plugins and check whether the error occurs. If it disappears, activate them one by one until you find the one causing the problem.

Share
Didn't find a fix?The AI IT assistant is available 24/7. Describe the problem or send a screenshot of the error and get instructions for your case.Ask the AI IT assistant