The Problem
It is a frustrating but common scenario. Your WordPress homepage loads perfectly, but every link to a post or page returns a generic 404 Not Found error. This usually happens after a site migration, a domain change, or a plugin update. In most cases, the web server is looking for a physical folder or file that doesn't exist because it doesn't know how to handle "pretty permalinks" like /blog/my-awesome-post/.
The 60-Second Fix
Try this first. It solves the issue in about 90% of cases by forcing WordPress to rebuild its internal routing rules.
- Log in to your WordPress Admin dashboard.
- Go to Settings > Permalinks.
- Don't change any settings. Simply scroll to the bottom and click Save Changes.
- Refresh your broken page. If it works, your rewrite rules were just out of sync. If not, keep reading.
Why Is This Happening?
- Missing .htaccess: The file that directs traffic to
index.phpis missing or corrupted. - Mod_Rewrite is Off: Your Apache server doesn't have the required module enabled to handle custom URLs.
- Overridden Configs: Your server is told to ignore local
.htaccessfiles. - Nginx Configuration: Nginx doesn't use
.htaccessand requires a specific rule in the site's config file.
Fixing the Error on Apache Servers
1. Manually Recreate the .htaccess File
Sometimes WordPress lacks the permissions to write to your server. If the "Save Changes" trick failed, you'll need to do it manually. Use FTP or your hosting File Manager to find your root directory. Create a file named .htaccess and paste this standard code:
# 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
Make sure the file permissions are set to 644. This allows the server to read the file while keeping it secure from unauthorized edits.
2. Enable the Rewrite Module
If you manage your own VPS (like DigitalOcean or Linode), the rewrite module might be disabled. Run these commands to turn it on:
sudo a2enmod rewrite
sudo systemctl restart apache2
3. Update the VirtualHost (AllowOverride)
Your server might be ignoring your .htaccess file entirely. Open your site configuration file, usually located at /etc/apache2/sites-available/000-default.conf. Look for the <Directory> block for your web folder and ensure AllowOverride is set to All:
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Save the file and restart Apache to apply the changes.
Fixing the Error on Nginx Servers
Nginx does not recognize .htaccess files. If your internal pages return 404s, your server block is likely missing the rewrite logic. Open your Nginx configuration file (e.g., /etc/nginx/sites-available/your-site).
Locate the location / block and ensure it includes the try_files directive:
location / {
try_files $uri $uri/ /index.php?$args;
}
This line tells Nginx to look for the file or folder first. If it can't find them, it passes the request to index.php. Always test your config before restarting:
sudo nginx -t
sudo systemctl reload nginx
Edge Cases to Watch For
Security Plugin Interference
Plugins like iThemes Security or Wordfence often protect the .htaccess file by making it "read-only." If you can't save your permalink settings, try temporarily deactivating these plugins to see if the file becomes writeable again.
Local Development (WAMP/XAMPP)
On local Windows or Mac setups, the rewrite_module is often disabled by default. Click the Apache icon in your XAMPP/WAMP control panel, find httpd.conf, search for mod_rewrite, and remove the # at the beginning of the line.
How to Verify the Fix
- Use Incognito Mode: Browsers often cache 404 responses. Always test in a private window to ensure you're seeing the live site.
- Run a Header Check: Use
curlin your terminal to see the server's response code:
curl -I https://yourdomain.com/sample-post/
You want to see `HTTP/1.1 200 OK`.
- **The "Plain" Test:** Go to **Settings > Permalinks** and set it to "Plain." If your posts work now, the problem is definitely your server's rewrite configuration.

