Learn how to safely troubleshoot and fix WordPress permalink issues when all pages suddenly start returning 404 errors, without breaking your live site.
Overview: When All Your URLs Turn Into 404s
Sometimes a WordPress site that was working fine suddenly starts returning 404 errors on all or most pages and posts, even though you can still log into the dashboard. This is usually a permalink (URL structure) problem, not missing content.
This guide walks you through a safe, step-by-step process to diagnose and fix sitewide 404 errors caused by permalink issues.
Common Causes of Sitewide Permalink 404 Errors
Sitewide 404s usually appear after one of these changes:
- Server or hosting migration
- Switching from
httptohttps(or vice versa) - Changing permalink structure in Settings ? Permalinks
- Updating or installing security, caching, or redirection plugins
- Manual edits to the
.htaccessfile on Apache servers - Incorrect Nginx rewrite rules
The good news: in most cases, you can fix this without touching your database or content.
Step 1 – Confirm It’s a Permalink Issue (Not Missing Content)
Before changing anything, confirm that your content still exists in WordPress.
1.1 Check Pages and Posts in the Dashboard
- Log in to WordPress: Dashboard ? Pages ? All Pages.
- Open a few key pages (e.g., Home, Contact) in the editor.
- Click View from the top admin bar to open them in a new tab.
If the editor loads fine but the front-end URL shows a 404, it’s almost certainly a permalink or rewrite issue.
1.2 Test the Admin Bar “View” Links
From the editor, use the View Page or View Post link. If that URL also returns 404, the problem is not the menu or a broken link; it’s how the server is handling pretty URLs.
Step 2 – Flush Permalinks from the WordPress Dashboard
Flushing permalinks forces WordPress to regenerate its URL rewrite rules. This is safe and often resolves the issue immediately.
2.1 Re-save Permalink Settings
- Go to Dashboard ? Settings ? Permalinks.
- Note your current setting (for example, Post name).
- Without changing anything, scroll down and click Save Changes.
2.2 If That Doesn’t Work, Temporarily Switch Structures
- On the same page, temporarily choose a different structure, such as Plain.
- Click Save Changes.
- Switch back to your preferred structure (for most sites, Post name).
- Click Save Changes again.
What You Should See
- After re-saving, visit a few pages in a private/incognito window.
- Pages that were previously 404 should now load normally.
- Your menu links and internal links should work again without manual updates.
Step 3 – Check the .htaccess File (Apache Servers)
If you are on an Apache-based host and re-saving permalinks didn’t help, WordPress may not be able to write to your .htaccess file, or the file may be corrupted.
3.1 Locate .htaccess
Use your hosting file manager or an FTP/SFTP client:
- Connect to your site’s files.
- Open the public_html (or document root) folder.
- Look for a file named
.htaccessin the same folder aswp-config.php.
Tip: You may need to enable “show hidden files” to see .htaccess.
3.2 Back Up the Existing .htaccess
- Download a copy of
.htaccessto your computer. - Optionally, rename the server copy to
.htaccess-backupso you can restore it if needed.
3.3 Add the Default WordPress Rewrite Rules
Create a new .htaccess file in the same directory with this content (for a standard WordPress install in the web root):
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Save the file, then return to Settings ? Permalinks and click Save Changes once more.
What You Should See
- Reload a few pages that were returning 404.
- If the issue was a corrupted or missing
.htaccess, they should now load correctly. - If not, continue to the next step.
Step 4 – Check for Conflicts with Security, Caching, or Redirect Plugins
Some plugins modify rewrite rules or redirects and can accidentally break permalinks.
4.1 Temporarily Disable Likely Plugins
From Dashboard ? Plugins ? Installed Plugins, temporarily deactivate:
- Security plugins (firewalls, login protection)
- Caching plugins
- Redirection or SEO plugins that manage redirects
- Custom routing or multilingual plugins
After deactivating, re-save permalinks again in Settings ? Permalinks and test your pages.
4.2 Re-enable Plugins One by One
If permalinks start working after deactivation:
- Re-enable plugins one at a time.
- After each activation, test a few URLs in a new incognito window.
- When 404s return, you’ve found the conflicting plugin.
Check that plugin’s settings for redirect rules or URL rewriting, or contact the plugin developer/your web team.
Step 5 – Verify Server-Level Rewrite Configuration (Nginx or Custom Setups)
If your host uses Nginx or a custom stack, permalinks may rely on server configuration files instead of .htaccess.
5.1 Ask Your Host to Confirm Rewrite Rules
Open a support ticket with your hosting provider and include:
- A description of the issue: “All pretty permalinks return 404, but
/?p=123works.” - A link to an example 404 URL and the corresponding page in the dashboard.
- A request to confirm that the server is configured with standard WordPress rewrite rules.
Most managed WordPress hosts can fix this quickly at the server level.
5.2 Test a Plain URL
To confirm it’s a rewrite problem and not a missing page:
- Note the ID of a post or page (hover over the title in Pages ? All Pages and look for
post=123in the URL). - Visit
https://yourdomain.com/?p=123(replace 123 with your ID).
If that loads while https://yourdomain.com/sample-page/ does not, the database and content are fine; only the rewrite layer is broken.
Step 6 – Check for Conflicting Custom Code or Child Theme Functions
Occasionally, custom code in a theme or plugin can interfere with permalinks.
6.1 Temporarily Switch to a Default Theme
- Go to Dashboard ? Appearance ? Themes.
- Activate a default theme such as Twenty Twenty-Five.
- Re-save permalinks and test your URLs.
If permalinks work with the default theme, the issue may be in your theme’s functions.php or custom routing code.
6.2 Look for Custom Rewrite or Redirect Code
Ask your developer or web team to review:
functions.phpin your active theme or child theme- Any custom plugin that handles URLs, slugs, or redirects
- Code that uses
add_rewrite_rule(),add_rewrite_tag(), orwp_redirect()
What You Should See When It’s Fixed
Once the permalink issue is resolved:
- All existing pages and posts load at their normal URLs without 404 errors.
- Your main navigation menu links work as expected.
- Category and tag archive pages load correctly.
- Custom post type URLs (if used) also work.
Always test in an incognito/private window and, if you use caching, clear both your WordPress and server/host cache before final verification.
Preventing Future Permalink Breakages
To reduce the chance of this happening again:
- Avoid editing
.htaccessdirectly unless you know exactly what you’re doing. - Limit the number of plugins that manage redirects or URL rules.
- Document your current permalink structure and server environment before migrations.
- After major updates or migrations, immediately test a few key URLs.
When to Contact Compass Production or Your Developer
Reach out for professional help if:
- Re-saving permalinks and restoring
.htaccessdid not resolve the issue. - You suspect Nginx or server-level configuration problems.
- Your site uses complex custom post types, multilingual routing, or advanced redirect logic.
Provide a list of example URLs that fail, a description of recent changes (plugins, migrations, SSL), and any error messages from your host. This will help your support team resolve the issue faster and with less risk to your live site.
Video