Make WordPress Core

Opened 2 years ago

Closed 22 months ago

Last modified 15 months ago

#61931 closed defect (bug) (fixed)

sitemap.xml redirect no longer works when using custom permalinks

Reported by: gmariani405 Owned by: swissspidy
Priority: normal Milestone: 6.7
Component: Sitemaps Version: 5.5
Severity: normal Keywords: has-patch commit has-screenshots has-test-info has-unit-tests
Cc: Focuses:

Description

The XML sitemap functionality from WordPress 5.5 fails to handle the /sitemap.xml -> /wp-sitemap.xml redirect if custom permalinks are used. If you use any of the built-in permlinks modes, the redirect functions fine, but if you set it to a custom permalink that is dis-similar to the built-in ones it breaks because it is only looking to pull values from the built-in regular expression matches. The /wp-sitemap.xml itself still continues to work.

In the sites where the redirect breaks, I have this as the Custom Structure:

/%category%/%postname%/
/%category%/%year%/%monthnum%/%postname%/

Change History (14)

#1 @swissspidy
2 years ago

  • Milestone Awaiting Review6.7
  • Version trunk5.5

This ticket was mentioned in PR #7249 on WordPress/wordpress-develop by @swissspidy.


2 years ago
#2

  • Keywords has-patch added

@swissspidy commented on PR #7249:


2 years ago
#3

cc @pbiron

@euthelup commented on PR #7249:


22 months ago
#4

After testing this case I can confirm the issue on wordpress:trunk branch. With a custom permalink set, if I try to visit http://localhost:8889/sitemap.xml I get a redirect to the "404 - not found" template.

After switching to swissspidy:fix/61931-sitemap-redirect when I visit http://localhost:8889/sitemap.xml I get a redirect to http://localhost:8889/wp-sitemap.xml and I can see the proper Sitemap template.

Good job! 👍

#5 @swissspidy
22 months ago

  • Keywords commit added
  • Owner set to swissspidy
  • Status newaccepted

@peterwilsoncc commented on PR #7249:


22 months ago
#6

Are you able to add a test case for the permalink structures noted in the ticket?

#7 @krupajnanda
22 months ago

  • Keywords has-screenshots has-testing-info added

Hi @peterwilsoncc

Test Report

Description

This report validates whether the indicated patch works as expected.

Patch tested: https://github.com/WordPress/wordpress-develop/pull/7249

Environment

  • WordPress: 6.7-alpha-58576-src
  • PHP: 8.2.15
  • Server: nginx/1.25.3
  • Database: mysqli (Server: 8.0.36 / Client: mysqlnd 8.2.15)
  • Browser: Chrome 129.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Four 1.2
  • MU Plugins:
    • Safe Autoloaded Options Limit Test (MU Plugin) 1.0
  • Plugins:
    • Test Reports 1.1.0

Actual Results

  1. ✅ Issue resolved with patch.

Additional Notes

  • Scenarios I checked :
    • Fresh WordPress Setup
    • Default Permalink, URL redirection ✅
    • Custom Permalink, URL redirection ✅

Supplemental Artifacts

Please check the visual here : https://drive.google.com/file/d/1gm_0T3o4doJi-fmmEysmyYuUR9De7Q5z/view?usp=drive_link

This ticket was mentioned in Slack in #core by chaion07. View the logs.


22 months ago

#9 @chaion07
22 months ago

Thanks @gmariani405 for reporting this. We reviewed this Ticket during a recent bug-scrub session. Kudos to Krupa for adding the Test Reports and acknowledging that the patch is working as expected. We also believe that this is ready for commit. Thanks.

Props to @krupajnanda for the Test Results and @pratiklondhe for the discussion.

Cheers!

#10 @swissspidy
22 months ago

  • Keywords has-unit-tests added

#11 @swissspidy
22 months ago

  • Resolutionfixed
  • Status acceptedclosed

In 59228:

Sitemaps: Improve sitemap.xml redirects when using custom permalinks.

Changes the way redirects from sitemap.xml to wp-sitemap.xml happen, so that they also work when using a more complex custom rewrite structure.

Props gmariani405, swissspidy, euthelup, peterwilsoncc.
Fixes #61931.

#12 @swissspidy
22 months ago

In 59229:

Sitemaps: Add missing _deprecated_function() call to newly deprecated method.

Follow-up to [59228].

See #61931.

#14 @wordpressdotorg
15 months ago

  • Keywords has-test-info added; has-testing-info removed
Note: See TracTickets for help on using tickets.