WordPress.org

Make WordPress Core

Opened 3 months ago

Last modified 2 weeks ago

#51662 new defect (bug)

Pagination adds extra trailing slash at the end of some URLs

Reported by: thornsteps Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.5.1
Component: Rewrite Rules Keywords:
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 (4)

#1 follow-up: @lukecarbis
2 weeks ago

Is this a duplicate of #52057?

#2 in reply to: ↑ 1 @thornsteps
2 weeks ago

Replying to lukecarbis:

Is this a duplicate of #52057?

I think it's similar. I opened this ticket 2 months ago 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.

Last edited 2 weeks ago by thornsteps (previous) (diff)

#3 @kaderavek
2 weeks ago

#52057 was marked as a duplicate.

#4 @SergeyBiryukov
2 weeks 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.

Note: See TracTickets for help on using tickets.