Make WordPress Core

Opened 3 years ago

Last modified 3 months ago

#51662 new defect (bug)

Pagination adds extra trailing slash at the end of some URLs

Reported by: thornsteps's profile thornsteps Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.5.1
Component: Rewrite Rules Keywords: has-patch
Focuses: Cc:

Description

WordPress 5.5.1 pagination adds extra trailing slash at the end of some URLs.

Normally, our website's URLs don't have trailing slash at the end of the URL.

We have found some bug on the_posts_pagination() function on WordPress 5.5.1.

[At page 2 of a category]https://stepstraining.co/strategy/page/2:
Previous link = https://stepstraining.co/strategy/
Page 1 link = https://stepstraining.co/strategy/

[At page 3 or more than page 3 of a category]https://stepstraining.co/strategy/page/3:
Page 1 link = https://stepstraining.co/strategy/

All of the above URLs will 301 redirect to https://stepstraining.co/strategy --it should not have trailing slash at the end of the URL in the first place.

[At page 2 of a tag]https://stepstraining.co/seo/page/2:
Previous link = https://stepstraining.co/seo/
Page 1 link = https://stepstraining.co/seo/

[At page 3 or more than page 3 of a tag]https://stepstraining.co/seo/page/3:
Page 1 link = https://stepstraining.co/seo/

All of the above URLs will 301 redirect to https://stepstraining.co/seo --it should not have trailing slash at the end of the URL in the first place.

The bug was gone when we tested adding untrailingslashit() to below code:
File : /wp-includes/general-template.php
esc_url( apply_filters( 'paginate_links', untrailingslashit($link) ) ),

Change History (6)

#1 follow-up: @lukecarbis
3 years ago

Is this a duplicate of #52057?

#2 in reply to: ↑ 1 @thornsteps
3 years ago

Replying to lukecarbis:

Is this a duplicate of #52057?

I think it's similar. I opened this ticket 2 months ago (#52057) and still have this problem on WordPress 5.5.3 .

At first, we don't have this bug until one day we did SEO checking again and found it.

Version 0, edited 3 years ago by thornsteps (next)

#3 @kaderavek
3 years ago

#52057 was marked as a duplicate.

#4 @SergeyBiryukov
3 years ago

  • Summary changed from WordPress 5.5.1 pagination adds extra trailing slash at the end of some URLs to Pagination adds extra trailing slash at the end of some URLs

Adjusting the title, as the issue is not specific to WordPress 5.5.1 and was likely introduced earlier.

#5 @djovanov
4 months ago

Same issue, reproduced on WordPress 6.22 and Twenty Twenty Two on fresh install, without plugin's.
Any workaround solution ?

This ticket was mentioned in PR #4684 on WordPress/wordpress-develop by @jignesh.nakrani.


3 months ago
#6

  • Keywords has-patch added
Note: See TracTickets for help on using tickets.