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 clicking on any page, post or link returns a "404 Not Found" error, the problem is almost certainly related to your permalink settings or your server's URL handling, not to your actual content.
This is different from a single missing page, which usually means that specific page has been deleted, moved to draft or had its URL changed. When every page except the homepage returns a 404, it's a structural issue with how your server translates the clean, readable URLs that WordPress uses (like example.com/about/) into the internal instructions WordPress needs to find the right content.
This is one of the most common WordPress issues, particularly after migrations, server changes, hosting provider switches and WordPress or plugin updates. The good news is that it's also one of the quickest to fix in most cases.
How WordPress permalinks work
Understanding the basics of how permalinks work makes the rest of this guide much clearer.
When you visit a URL like example.com/about/, there isn't actually a folder called "about" on your server with a file inside it. Instead, your web server is configured to send requests like this to WordPress's index.php file, which then reads the URL, looks up the matching content in the database and displays the right page.
The instructions that tell your web server to do this are called rewrite rules. On Apache servers (the most common type), these rules are stored in a file called .htaccess in your WordPress root directory. WordPress generates these rules automatically based on your permalink settings.
If these rules are missing, corrupted or not being read by the server, the server doesn't know to send requests to WordPress. Instead, it looks for a literal file or folder matching the URL, doesn't find one and returns a 404 error. The homepage still works because it doesn't need rewrite rules; it's the default page the server loads for the root domain.
Resave your permalink settings
The simplest fix, and the one that works most often, is to tell WordPress to regenerate its rewrite rules.
Go to Settings → Permalinks in the WordPress dashboard. You don't need to change anything at all. Simply click Save Changes at the bottom of the page. This tells WordPress to flush its internal rewrite rules and, on Apache servers, to rewrite the .htaccess file with fresh rules.
After saving, visit one of the pages that was returning a 404 and refresh it. If it loads correctly, the problem is solved.
This fix works because the rewrite rules can become stale or out of sync after WordPress updates, plugin activations or deactivations, server configuration changes or migrations. Resaving the permalink settings forces WordPress to rebuild them from scratch.
Regenerate your .htaccess file
If resaving permalinks didn't fix the issue, the .htaccess file itself may be corrupted, missing or not writable by WordPress.
Connect to your site via FTP, SFTP or your hosting file manager and navigate to the WordPress root directory (the same folder that contains wp-config.php and the wp-content folder).
First, check whether .htaccess exists. If the file is missing entirely, WordPress wasn't able to create it, usually because of file permission restrictions. If the file exists but the 404s persist, it may contain corrupted or conflicting rules.
If the file exists, rename it to .htaccess_old to keep it as a backup. Then go to Settings → Permalinks in the WordPress dashboard and click Save Changes to generate a fresh .htaccess file.
Check the file permissions on the new .htaccess. It should be set to 644, which allows WordPress to read and write to it. If the permissions are more restrictive, WordPress won't be able to update the file when permalink settings change in the future.
If WordPress can't create the file automatically (which can happen on some hosting configurations), you can create it manually. Create a new file called .htaccess in the WordPress root directory and add the following default WordPress 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
In simple terms, these rules tell the server: "If someone requests a URL that doesn't match a real file or folder on the server, send the request to WordPress's index.php file and let WordPress figure out what to display."
If WordPress is installed in a subdirectory rather than the root of your domain (for example, example.com/blog/ rather than example.com/), change the RewriteBase / line to match your subdirectory, such as RewriteBase /blog/.
Check that your server supports URL rewriting
On Apache servers, WordPress permalinks require a server module called mod_rewrite to be enabled. This module is what processes the rewrite rules in your .htaccess file. If it's been disabled (for example, after a server configuration change or a hosting migration), no amount of .htaccess editing will fix the 404 errors because the server isn't processing the rules at all.
You can check whether mod_rewrite is active by going to Tools → Site Health → Info → Server in the WordPress dashboard and looking for it in the list of loaded Apache modules.
If it's not listed, contact your hosting provider and ask them to enable mod_rewrite. This is a server-level setting that you typically can't change yourself on shared hosting, but hosting providers enable it routinely since it's required by most modern web applications.
Nginx servers: a different configuration
If your server runs Nginx rather than Apache, the .htaccess file doesn't apply. Nginx doesn't read .htaccess files at all, which is a very common source of confusion when migrating a WordPress site from an Apache server to an Nginx server. Your .htaccess file might be present and contain all the correct rules, but Nginx simply ignores it.
Nginx uses its own configuration files to handle URL rewriting, and the rewrite rules for WordPress need to be added to the server's Nginx configuration rather than to a file in your WordPress directory. This is typically set up by your hosting provider as part of the WordPress installation.
If you're on Nginx and experiencing 404 errors on all pages, contact your hosting provider and ask them to verify that the WordPress rewrite rules are present in your Nginx configuration. The required rules are documented in the official WordPress Nginx guide, which your hosting provider will be familiar with.
Fix plugin-related 404 errors
If the 404 errors only affect a specific type of content rather than all pages and posts, the issue may be related to a plugin that registers its own content types or URL structures.
Many WordPress plugins create their own types of content (for example, a portfolio plugin might create "portfolio" items, an events plugin might create "events" and WooCommerce creates "products"). Each of these registers its own URL structure, and the rewrite rules for these need to be generated alongside the standard WordPress rules.
If a plugin's content is returning 404 errors, try deactivating and then reactivating the plugin. This forces WordPress to re-register the plugin's URL structure. Then go to Settings → Permalinks and click Save Changes to flush the rewrite rules.
If the 404 errors started after installing or updating a plugin, check whether the plugin's URL structure conflicts with an existing page. For example, if a plugin creates URLs under /projects/ and you also have a WordPress page with the slug "projects," they can conflict and cause 404 errors on one or both.
Fix WooCommerce product 404 errors
WooCommerce products follow the same rewrite rule system as the rest of WordPress, so all of the general fixes above apply. However, WooCommerce product 404s have a few additional causes worth checking.
Start by resaving your permalinks from Settings → Permalinks as described above. WooCommerce registers its own URL structure for products, and this needs to be included in the rewrite rules.
If products are still returning 404 errors, check the following WooCommerce-specific settings.
Under WooCommerce → Settings → Advanced → Permalinks, verify that the product permalink base is set correctly. If it conflicts with an existing page slug, it can cause 404 errors. For example, if your product base is set to /shop/ but you also have a WordPress page with the slug "shop" that isn't the WooCommerce shop page, they can conflict.
Check the individual product's visibility settings by editing the product and looking at the Publish panel. A product set to "Hidden" in the catalogue visibility settings should still be accessible by its direct URL. If it's returning a 404 instead, the problem is more likely a rewrite rule issue than a visibility setting.
Also check the product's stock status. While out-of-stock products shouldn't return 404 errors by default, some themes or plugins alter this behaviour and redirect or hide out-of-stock products. If you suspect this is happening, try switching to a default theme temporarily to test.
Check for redirect plugin conflicts
Plugins that manage redirects, handle SEO or modify WordPress's URL structure can all interfere with permalink routing and cause 404 errors.
If the 404 errors started after installing or updating a plugin, try deactivating it and testing whether the pages load. If 404 errors appeared without any obvious recent change, deactivate plugins one at a time (starting with any SEO, redirect or URL-related plugins) and test after each one.
Need help with persistent 404 errors?
If pages and posts keep returning 404 errors after working through these steps, there may be a deeper server configuration issue that requires access beyond what's available through WordPress. My emergency WordPress support service can help diagnose and resolve permalink, server configuration and URL rewriting issues.