fix: 301 stale main-domain festival_wire sitemap URLs to wire subsite#71
Open
chubes4 wants to merge 1 commit into
Open
fix: 301 stale main-domain festival_wire sitemap URLs to wire subsite#71chubes4 wants to merge 1 commit into
chubes4 wants to merge 1 commit into
Conversation
The festival_wire CPT is registered by extrachill-news-wire, which is
per-site active only on the wire subsite (blog 11). The main blog has
zero festival_wire posts and never registers the CPT, so both
wp-sitemap-posts-festival_wire-1.xml and -2.xml return HTTP 404 on the
main domain. Google retains these URLs from a legacy era when Festival
Wire lived on the main blog.
Extend ec_handle_legacy_path_redirects() to 301 any
^/wp-sitemap-posts-festival_wire-(\d+)\.xml$ on the main domain to the
matching URL on the wire subsite, reusing ec_get_site_url('wire') (no
hardcoded domain) and passing the page number through so it works for
any page count as wire grows.
Fixes Extra-Chill/extrachill-seo#29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
The
festival_wireCPT is registered by extrachill-news-wire, which is per-site active only on the wire subsite (blog 11, wire.extrachill.com). The main site (blog 1) has 0festival_wireposts and never registers the CPT, so both:https://extrachill.com/wp-sitemap-posts-festival_wire-1.xmlhttps://extrachill.com/wp-sitemap-posts-festival_wire-2.xmlreturn HTTP 404. Google retains these from a legacy era when Festival Wire lived on the main blog. The wire subsite serves them correctly (200) at
https://wire.extrachill.com/wp-sitemap-posts-festival_wire-N.xml.There was already a legacy-redirect handler for festival-wire content paths in
inc/core/legacy-path-redirects.php(ec_handle_legacy_path_redirects()ontemplate_redirectpriority 1), but it did not cover the sitemap URLs.Change
Extends the existing handler to also 301 the stale sitemap URLs on the main domain.
Regex → redirect mapping:
$1is passed through, so it works for any page count as wire grows (currently pages 1 and 2).ec_get_site_url('wire')helper for the wire base — no hardcoded domain.$wire_urlresolution was moved up a few lines so both the sitemap branch and the existing content-path branch share it. Behavior is equivalent: ifec_get_site_url('wire')is unavailable, neither redirect can function, so an early return for all paths is correct.Verification
php -lclean.phpcs --standard=WordPressclean (0 errors, 0 warnings)./wp-sitemap-posts-festival_wire-1.xmland-2.xml(and multi-digit pages), captures the page number, and does not match the/festival-wire/*content path owned by the existing handler nor unrelatedwp-sitemap-posts-post-N.xmlURLs.Fixes Extra-Chill/extrachill-seo#29