After switching to "Post name" permalinks, the home page works but every post and page gives 404 Not Found. Settings > Permalinks > Save did nothing.
#wordpress#permalinks#htaccess
DEV3 Developer Forum
Every post is reviewed first. Usually reviewed within 24 hours.
After switching to "Post name" permalinks, the home page works but every post and page gives 404 Not Found. Settings > Permalinks > Save did nothing.
#wordpress#permalinks#htaccess
Pretty permalinks need the web server to send unknown paths to index.php. If the rewrite rules are missing or ignored, you get a server 404.
Apache: confirm .htaccess exists in the WordPress root and contains:
# 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
If WordPress cannot write the file, make it writable temporarily or paste the block yourself. Also check the virtual host has AllowOverride All for the site directory and that mod_rewrite is enabled (sudo a2enmod rewrite, then restart Apache).
Nginx ignores .htaccess. The location block must fall back to index.php:
location / {
try_files $uri $uri/ /index.php?$args;
}
Other checks
wp rewrite flush.?p=123) work without rewrites, so they are a good test of whether rewriting is the problem.Never call flush_rewrite_rules() on every request. Run it once on plugin activation only.