Repository navigation
Platform mu-plugin always 301s /sitemap.xml and blocks third-party sitemaps #4325
Description
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:
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:
-
After core#61931 (6.7), Core does not 301
/sitemap.xmlto/wp-sitemap.xml.WP_Sitemaps::redirect_sitemapxml()is deprecated. Core registers an internal rewrite inWP_Rewrite::rewrite_rules():sitemap.xml→index.php?sitemap=indexSame query as
wp-sitemap.xml(WP_Sitemaps::register_rewrites()). The sitemap is served at/sitemap.xml. The old redirect was only for when/sitemap.xmlwas parsed as a page namedsitemap-xml. -
“Installed at the root” in that Core block is
home_url()path empty or/— the same guard asrobots.txtandfavicon.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.xmlfor subdirectory or subdomain installs. A subdomain is not a Playground-only edge case. -
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.xmlcan 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):
- Open https://playground.wordpress.net/?url=%2Fsitemap.xml (or
@wp-playground/cliserver, then request/sitemap.xmlwithout following redirects). - See
301Location: /wp-sitemap.xml. - 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:
- Same vanilla site, default theme.
- Activate only a plugin that serves
/sitemap.xml(example: The SEO Framework). - Open
/sitemap.xml. - See a 301 to
/wp-sitemap.xmlinstead 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