Menu

When to Flush WordPress Rewrite Rules: Fixing 404s After Permalink or Post Type Changes
📰

When to Flush WordPress Rewrite Rules: Fixing 404s After Permalink or Post Type Changes

DEV Community: php·Susumu Takahashi·11 days ago
#moIY9vnE
#devto#dev#rules#rewrite#flush
Long article (1109 words) — no AI summary yet.
Reading 0:00
15s threshold

"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…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.