DEV3 Technologies home

DEV3 Developer Forum

Why do my WordPress pages return 404 after changing permalinks?

WordPress helpSolved0 views
dev3 ·

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

0

1 reply

dev3 · Accepted answer

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

  • Visit Settings > Permalinks and click Save once more, which flushes the rules.
  • A custom post type or taxonomy registered after changing code needs a flush: wp rewrite flush.
  • Plain permalinks (?p=123) work without rewrites, so they are a good test of whether rewriting is the problem.
  • Caching plugins and CDNs may serve a stale 404; purge them.

Never call flush_rewrite_rules() on every request. Run it once on plugin activation only.

0

Your reply

Every post is reviewed by DEV3 before it appears. Usually reviewed within 24 hours.

Markdown supported. Use ``` for code blocks. Images are not allowed.