"I added a custom post type and both the archive and single pages return 404." "I changed the permalink structure and only some URLs stopped working." These are familiar symptoms in WordPress maintenance, and the cause is often stale rewrite rules .
This article explains what rewrite rules are, where they are stored, and when they need to be regenerated ("flushed"). It describes general WordPress behavior, not any specific product.
Note: The basics of Apache's .htaccess and mod_rewrite are covered in a separate article . This one is about the layer inside it: WordPress's own rules .
Two different "rewrites"
URL handling in WordPress has two stages with different jobs.
Stage Handled by Role
1 Web server ( .htaccess etc.) Passes requests for non-existent files or directories to index.php
2 WordPress core (rewrite rules) Translates the URL that reached index.php into a query for a post or archive
A request for /news/2026/hello/ is handed to index.php at stage 1, then interpreted at stage 2 as something…