Skip to content

Fix: 404 pages returning 200 OK with frontpage in Multisite#6

Closed
Copilot wants to merge 1 commit intofix/verbose-page-rules-404from
copilot/sub-pr-4
Closed

Fix: 404 pages returning 200 OK with frontpage in Multisite#6
Copilot wants to merge 1 commit intofix/verbose-page-rules-404from
copilot/sub-pr-4

Conversation

Copy link

Copilot AI commented Jan 16, 2026

WordPress Multisite enables use_verbose_page_rules by default, causing non-existent pages to return 200 OK with frontpage content instead of proper 404 responses.

Changes

  • Disable use_verbose_page_rules in init hook (priority 1) to override WordPress/Multisite defaults
  • Ensures correct 404 behavior regardless of permalink structure
  • Requires rewrite flush after deployment: wp rewrite flush or save permalink settings

Technical Details

The root cause: WordPress validates page existence before accepting rewrite matches. With verbose page rules enabled, failed matches fall back to frontpage with empty query_vars and 200 status.

Setting use_verbose_page_rules = false generates more specific rewrite rules that fail properly when pages don't exist, triggering correct 404 responses.

add_action('init', function () {
    global $wp_rewrite;
    $wp_rewrite->use_verbose_page_rules = false;
}, 1);

Test Plan

  • Visit non-existent URL (e.g., /this/page/does/not/exist) → verify 404
  • Visit valid pages (single and hierarchical) → verify still work
  • Flush rewrite rules after deployment

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix 404 pages returning 200 OK in Multisite Fix: 404 pages returning 200 OK with frontpage in Multisite Jan 16, 2026
Copilot AI requested a review from jeanfredrik January 16, 2026 18:49
@jeanfredrik jeanfredrik closed this Feb 2, 2026
@jeanfredrik jeanfredrik deleted the copilot/sub-pr-4 branch February 2, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants