How to Fix WordPress Permalinks Not Working (404 on All Pages Except Homepage)
Google AdSense In-Article Display Placement
Publisher ID: ca-pub-XXXXXXXXXXXXXXXX (Configured in config.php)When the homepage loads perfectly but clicking any post or page results in a 404 Not Found error, the web server is looking for physical files on disk instead of routing requests to index.php.
1) In WP-Admin, navigate to Settings -> Permalinks and click "Save Changes". 2) If on an Apache VPS or XAMPP, open "httpd.conf", locate "<Directory /var/www/html>", and change "AllowOverride None" to "AllowOverride All". 3) Ensure .htaccess has permission 644.
📋 Guide Table of Contents
1. Problem Diagnosis & Symptoms
Pretty permalinks (/sample-post/) require URL rewriting. Without rewrite rules, Apache searches for a directory named /sample-post/ and fails.
2. Primary Root Causes
- Cause: Missing or empty .htaccess file.
- Cause: AllowOverride set to None in main Apache configuration.
3. Step-by-Step Diagnostic Fixes
Restore Default WordPress .htaccess
Create .htaccess in root with standard rules:
# 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
4. How to Verify the Resolution
- Click internal post links and confirm they load with 200 OK.
5. Diagnostic Troubleshooting Matrix
| Symptom Observed | Root Cause | Recommended Action |
|---|---|---|
| Permalinks work on Plain (?p=123) but fail on Post Name | mod_rewrite disabled or .htaccess ignored | Enable mod_rewrite and verify AllowOverride All in Apache |
6. Critical Mistakes to Avoid
- ❌ Setting .htaccess permissions to 777.
7. Frequently Asked Questions
❓ Does Nginx use .htaccess for WordPress permalinks?
No, Nginx does not read .htaccess. You must add try_files $uri $uri/ /index.php?$args; in the Nginx server block.
Official Technical References
Google AdSense In-Article Matched Content Unit