Fixing WordPress permalink issues and 404 errors

How to fix WordPress pages and posts returning 404 errors when the homepage loads fine, covering permalink settings, .htaccess regeneration, server configuration and WooCommerce product 404s.

Fixing WordPress permalink issues and 404 errors

If your WordPress homepage loads fine but every other page, post or custom post type returns a 404 "not found" error, the problem is almost always related to your permalink settings or your server's URL rewriting configuration.

This is different from a single missing page (which usually means the content has been deleted or moved to draft). When every page except the homepage returns a 404, it's a structural issue with how your server handles URLs rather than a content problem.

The good news is that this is usually one of the quickest WordPress issues to fix.

The simplest fix, and the one that works most often, is to flush and regenerate your permalink structure.

Go to Settings → Permalinks in the WordPress dashboard. You don't need to change anything. Simply click Save Changes at the bottom of the page. This tells WordPress to regenerate its rewrite rules and, on Apache servers, to update the .htaccess file.

Refresh one of the pages that was returning a 404. If it loads, the problem is solved. This fix works because the rewrite rules that tell your server how to translate clean URLs into WordPress queries can become stale or corrupted, particularly after updates, migrations or server configuration changes.

Regenerate .htaccess

If resaving permalinks didn't work, the .htaccess file in your WordPress root directory may be corrupted, missing or not writable.

Connect via FTP, SFTP or your hosting file manager and check whether .htaccess exists in the same directory as wp-config.php. If it's missing, WordPress may not have been able to create it (usually due to file permissions).

If the file exists, rename it to .htaccess_old and then resave your permalinks from Settings → Permalinks to generate a fresh one. Check the file permissions on the new .htaccess. It should be set to 644 so WordPress can read and write to it.

If WordPress can't create the file automatically, you can create it manually. Create a new file called .htaccess in the WordPress root directory with the following default WordPress rewrite rules:

# 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

If WordPress is installed in a subdirectory rather than the root, adjust the RewriteBase value to match (for example, RewriteBase /blog/).

Check that mod_rewrite is enabled

On Apache servers, WordPress permalinks require the mod_rewrite module to be enabled. If it's been disabled (for example, after a server configuration change or a hosting migration), no amount of .htaccess editing will fix the 404s because the server isn't processing rewrite rules at all.

You can check whether mod_rewrite is enabled under Tools → Site Health → Info → Server in the WordPress dashboard. If it's not listed as active, contact your hosting provider and ask them to enable it.

Check Nginx configuration

If your server runs Nginx rather than Apache, there is no .htaccess file. Nginx doesn't read .htaccess files, which is a common source of confusion when moving a WordPress site from an Apache server to Nginx.

Nginx requires its own rewrite rules to be added to the server configuration file. Your hosting provider should handle this as part of the WordPress setup, but if the rules are missing or incorrect, every page except the homepage will return a 404.

Contact your hosting provider and ask them to verify that the Nginx configuration includes the standard WordPress rewrite rules. The required configuration block is documented in the official WordPress Nginx documentation.

Check for custom post type issues

If the 404s only affect a specific type of content (such as a custom post type created by a plugin), the issue may be that the post type's rewrite rules need to be flushed.

Deactivate and reactivate the plugin that registers the custom post type, then go to Settings → Permalinks and click Save Changes. This forces WordPress to regenerate its rewrite rules including those for the custom post type.

If the 404s persist for the custom post type, check whether the post type's URL slug conflicts with an existing page slug. For example, if you have a custom post type with the slug "projects" and also a page called "Projects," they can conflict and cause 404s on one or both.

Fix WooCommerce product 404s

WooCommerce products are a custom post type, so they can be affected by all of the general permalink issues above. However, WooCommerce product 404s have a few additional causes.

Check the product's visibility under Edit Product → Publish → Catalogue visibility. A product set to "Hidden" won't appear in search results or the shop page, but it should still be accessible by direct URL. If it's returning a 404 instead, the issue is more likely a permalink or rewrite problem.

Also check the product's stock status. While out-of-stock products shouldn't return 404s by default, some themes or plugins change this behaviour and hide or redirect out-of-stock products.

WooCommerce has its own permalink settings under WooCommerce → Settings → Advanced → Permalinks. Make sure the product permalink base is set correctly and doesn't conflict with an existing page.

After checking WooCommerce-specific settings, resave your permalinks from Settings → Permalinks to flush the rewrite rules.

Check for conflicting plugins

Plugins that modify URLs, handle redirects, manage custom post types or alter WordPress's rewrite rules can all cause 404 errors.

If the 404s started after installing or updating a plugin, try deactivating it. If 404s appeared without any obvious change, deactivate plugins one at a time and test whether the pages load after each one.

SEO plugins, redirect management plugins and plugins that modify the WordPress admin URL are common culprits.

Need help with persistent 404s?

If pages and posts keep returning 404 errors after working through these steps, my emergency WordPress support service can help diagnose and resolve permalink, server configuration and URL rewriting issues.

Adam Greenough

Written by Adam Greenough

Freelance web developer with over 15 years of experience building and fixing WordPress sites. I work with businesses across the UK on everything from emergency support to full builds.

Need hands-on help?

I offer emergency WordPress support with a no-fix, no-fee guarantee.