Skip to content

Platform mu-plugin always 301s /sitemap.xml and blocks third-party sitemaps #4325

Open

Description

@sybrew

Prerequisites

  • I have carried out troubleshooting steps and I believe I have found a bug.
  • I have searched for similar bugs in both open and closed issues and cannot find a duplicate.

Describe the bug

writeCommonPlatformMuPlugins() writes /internal/shared/mu-plugins/sitemap-redirect.php on every boot:

https://github.com/WordPress/wordpress-playground/blob/trunk/packages/playground/wordpress/src/platform-mu-plugins.ts

That file runs at muplugins_loaded and header() + exits any {site path}/sitemap.xml request (including ?… and /…) to {site path}/wp-sitemap.xml with a 301. WordPress rewrite matching and regular plugins never see the URL. There is no filter and no opt-out.

The comment says this is for “non-root installations” because Core only adds a sitemap.xml → wp-sitemap.xml rewrite at the domain root, and cites #2051.

That comment is wrong on three points:

  1. After core#61931 (6.7), Core does not 301 /sitemap.xml to /wp-sitemap.xml. WP_Sitemaps::redirect_sitemapxml() is deprecated. Core registers an internal rewrite in WP_Rewrite::rewrite_rules():

    sitemap.xml → index.php?sitemap=index

    Same query as wp-sitemap.xml (WP_Sitemaps::register_rewrites()). The sitemap is served at /sitemap.xml. The old redirect was only for when /sitemap.xml was parsed as a page named sitemap-xml.

  2. “Installed at the root” in that Core block is home_url() path empty or / — the same guard as robots.txt and favicon.ico. A subdomain (blog.example.com/) is root. A subdirectory (example.com/blog/) is not. There is no Trac ticket asking Core or Playground to 301 /sitemap.xml for subdirectory or subdomain installs. A subdomain is not a Playground-only edge case.

  3. playground.wordpress.net and CLI http://127.0.0.1:PORT/ are root. sitemap.xml does not render for WordPress 6.7 in Playground web app #2051 / [Website] Fix sitemap.xml redirect to wp-sitemap.xml  #3140 already flush rewrite rules so Core’s rule exists. This mu-plugin still 301s those sites.

Playground should not special-case this URL. Any WordPress site can run on a subdomain; that is Core's root case.

Expected behavior

Playground does not intercept /sitemap.xml.

  • Vanilla, pretty permalinks, site at /: Core's rewrite may serve the Core sitemap at /sitemap.xml (200). No platform 301.
  • A sitemap plugin that owns /sitemap.xml can respond. Playground does not steal the request first.

Actual behavior

Every {site path}/sitemap.xml request gets:

Status: 301 Location: {site path}/wp-sitemap.xml

On a vanilla site this looks “correct” because /wp-sitemap.xml then serves Core's sitemap. It is still not what Core does after 6.7, and it hides the hijack.

With a plugin that serves /sitemap.xml (e.g., The SEO Framework), the plugin sitemap is never returned.

Steps to reproduce

Vanilla (no extra plugins):

  1. Open https://playground.wordpress.net/?url=%2Fsitemap.xml (or @wp-playground/cli server, then request /sitemap.xml without following redirects).
  2. See 301 Location: /wp-sitemap.xml.
  3. On a normal root WordPress 6.7+ install with pretty permalinks, the same URL is an internal rewrite, not this 301.

With a sitemap plugin:

  1. Same vanilla site, default theme.
  2. Activate only a plugin that serves /sitemap.xml (example: The SEO Framework).
  3. Open /sitemap.xml.
  4. See a 301 to /wp-sitemap.xml instead of the plugin's sitemap XML.

Isolating the problem

  • I have deactivated other plugins and confirmed this bug occurs when only this plugin is active.
  • This bug happens with a default WordPress theme active.
  • I can reproduce this bug consistently using the steps above.

Activity

  1. added
    [Type] BugAn existing feature does not function as intended
    on Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions