WordPress permalinks not working: fixing the 404 on every page except home
Quick answer
When WordPress permalinks stop working and every URL except the home page returns 404, the Apache or Nginx rewrite rules are missing or broken. On Apache the fix is to open Settings > Permalinks in wp-admin and click Save Changes, which rewrites the htaccess block. If htaccess is not writable, paste the standard WordPress rewrite block into htaccess by hand. On Nginx, the try_files directive must be added to the server block by the host, since WordPress cannot write to Nginx config.
Why every page suddenly 404s
WordPress does not use real files for its pages. When you visit /about, Apache or Nginx has to know to hand the request off to index.php, and WordPress figures out what /about means from there.
Apache learns this from a small block of rewrite rules in htaccess. Nginx learns it from a try_files directive in the site config. If either goes missing, the home page still works because it hits index.php directly, but every other URL 404s.
The rewrite block usually goes missing because a migration replaced htaccess, a security plugin rewrote it, or the file permissions changed so WordPress can no longer update it.
The 60 second fix on Apache
- In wp-admin, open Settings > Permalinks. Do not change anything. Click Save Changes. WordPress rewrites the htaccess block.
- If htaccess is not writable, the Permalinks screen shows the exact block you need to paste. Copy it, paste it into htaccess in the site root, save.
- Test any internal URL. If it loads, you are done. If it still 404s, check that AllowOverride All is set for the site in the Apache vhost. Managed hosts always have this on; some VPS setups do not.
On Nginx there is no htaccess
Nginx ignores htaccess entirely. The rewrite has to live in the server block, and WordPress cannot write to it.
The standard directive is: try_files $uri $uri/ /index.php?$args; inside the location / block. Managed WordPress hosts on Nginx set this up automatically. On a bare VPS, you or your host must add it.
After the change, reload Nginx with nginx -s reload. There is no need to touch WordPress itself.
Common questions
Why does my home page work but every other page 404?+
Because the home page loads index.php directly, and every other URL depends on rewrite rules that turn a friendly URL into an index.php call. Missing rewrite rules break every URL except the home page.
Do I need to edit htaccess by hand?+
Usually no. Opening Settings > Permalinks and clicking Save Changes tells WordPress to rewrite the block itself. Editing by hand is only needed when htaccess is not writable.
Why did permalinks break after migrating hosts?+
Migrations often skip htaccess or overwrite it with a generic version. Re-save permalinks after any migration to regenerate the WordPress rewrite block cleanly.
Want this handled for you?
Book a call and we will review your site before recommending anything.