WordPress.org

Make WordPress Core

Opened 2 months ago

Last modified 2 months ago

#54010 new defect (bug)

Redirect from /sitemap.xml to /wp-sitemap.xml needs to be 301 and not 302

Reported by: RedBMedia Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.5
Component: Sitemaps Keywords:
Focuses: Cc:

Description

/sitemap.xml is the standard naming nomenclature for XML sitemaps submitted to search engines. It is widely accepted in the search community and is the defacto default for most automated sitemap tools. Because of the term's popularity when a user accesses this file off of the WordPress root they are automatically redirected via 302 to WordPress' builtin XML site map at /wp-sitemap.xml

This redirect should be a 301 not a 302, because 302's are ignored by search engines as they are meant to only be temporary. This issue is causing confusion for users that aren't familiar with the WordPress default and submitting /sitemap.xml instead to search engines who then ignore the redirect because it is a 302.

Change History (6)

#1 @SergeyBiryukov
2 months ago

  • Component changed from General to Sitemaps

#2 @pbiron
2 months ago

@RedBMedia Welcome back to trac, and thank you for the ticket.

@swissspidy and/or @jonoaldersonwp, do you have immediate thoughts on this?

#3 @pbiron
2 months ago

  • Version changed from 5.8 to 5.5

#4 follow-up: @jonoaldersonwp
2 months ago

Hey, Joe!

I'm on the fence. 302s are definitely problematic in that search engines won't typically/officially pass equity through them. However, there are a few moving parts here:

  • If a user changes their XML sitemap plugin, 301s are more likely to be cached (by browsers and intermediary systems like CDNs); that might cause problems when there's a long expiration window
  • We don't need to worry about equity in the case of sitemaps
  • If users are entering the wrong URL for their sitemap, this feels at least in part like a user/education problem
  • Submitting invalid sitemaps to Google Search Console / similar doesn't typically cause any harm

I think that the caching issue is significant enough to warrant us sticking with a 302, even though that's suboptimal.

Joe, do you have any examples of GSC not recognizing a 302'd sitemap? In my (admittedly brief, and singular) testing, it seems to follow it to the destination successfully. Might be other factors at play, though!

It might be a better route to get the GSC folks to fix this at their end; there are undoubtedly myriad sites - beyond WP - which serve sitemaps via a 302 redirect!

#5 in reply to: ↑ 4 @RedBMedia
2 months ago

Hey Jono! I agree that transferring equity doesn't matter. I am only concerned with submitting to search console. I had a error with a new client recently when they put the wrong URL in, and when I checked I noticed the 302 redirect. I'll double check it again and make sure its not a reoccurring issue. But as I assumed originally it would make sense that GSC would ignore the 302, even if they shouldn't. I know some of their crawl and render tools still handle the 302 the same way Googlebot does. But I'll double check again and see. You are likely right though.

Replying to jonoaldersonwp:

Hey, Joe!

I'm on the fence. 302s are definitely problematic in that search engines won't typically/officially pass equity through them. However, there are a few moving parts here:

  • If a user changes their XML sitemap plugin, 301s are more likely to be cached (by browsers and intermediary systems like CDNs); that might cause problems when there's a long expiration window
  • We don't need to worry about equity in the case of sitemaps
  • If users are entering the wrong URL for their sitemap, this feels at least in part like a user/education problem
  • Submitting invalid sitemaps to Google Search Console / similar doesn't typically cause any harm

I think that the caching issue is significant enough to warrant us sticking with a 302, even though that's suboptimal.

Joe, do you have any examples of GSC not recognizing a 302'd sitemap? In my (admittedly brief, and singular) testing, it seems to follow it to the destination successfully. Might be other factors at play, though!

It might be a better route to get the GSC folks to fix this at their end; there are undoubtedly myriad sites - beyond WP - which serve sitemaps via a 302 redirect!

#6 @jonoaldersonwp
2 months ago

Nice one. Definitely worth double-checking and confirming. I wouldn't be surprised if bits of those systems behave in completely arbitrary and inconsistent manners :D

Note: See TracTickets for help on using tickets.