WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 months ago

Last modified 3 months ago

#40773 closed defect (bug) (fixed)

Redirect paged requests for non-paginated posts to avoid duplicate content

Reported by: prografika Owned by: SergeyBiryukov
Milestone: 5.5 Priority: normal
Severity: normal Version: 2.9
Component: Canonical Keywords:
Focuses: Cc:

Description

Hello, I found the problem on the site in the latest version of WordPress. If we open a page or record on any site version 4.7.4 and add arbitrary numbers to the address, then instead of page 404 we will see a copy of the content.
For example:
Https://mybilet.info/moskva-gruziya-aviabilety/
And the same can be seen from the link
Https://mybilet.info/moskva-gruziya-aviabilety/6546/

Because of this, search engines define pages as non-canonical.

Change History (11)

#1 @subrataemfluence
3 years ago

I could reproduce the issue and tried to get some more information about it.

I have a page site.com/trips/dharamsala-deemed-smart-city/. If I add an arbitrary number to the end of it, the page still loads fine, e.g /trips/dharamsala-deemed-smart-city/9987, but if I add a non-numeric value in place of 9987, e.g. 98xx the page no longer comes up!

The first thing we need to know how this additional parameter is being treated by WordPress and why only numeric values are being accepted.

For the same above URL, the plain mode comes up as site.com/?trips=dharamsala-deemed-smart-city. Now if I add an additional parameter e.g. x=9987, the page loads. Even x=9987x does not prevent the page from loading with content!

If I haven't understood wrong, pretty permalinks actually encapsulate the real URL inside it by. I tried to get that actual underlying URL so that the query string parameters could be revealed but I couldn't. I was unable to find a function in core which outputs the above.

However, the first parameter in my URL is "trips" so if I add a number to end of this URL, WordPress still can match the first parameter value and finds the content.

But if above is true then why not with an alphanumeric value?
Also why both numeric and alphanumeric values are accepted when I use plan mode?

#2 @dd32
3 years ago

  • Version changed from 4.7.4 to 2.9

The original description sounded like a duplicate of #11694 which was fixed in 4.4.

It appears that the fix in #11694 / [34492] only applied to posts which have pages, when pagination doesn't exist, the redirects added there ignored.

#3 @SergeyBiryukov
19 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hi there, welcome to WordPress Trac!

Thanks for the report, we're already tracking this issue in #28081.

#4 @SergeyBiryukov
3 months ago

  • Component changed from Permalinks to Canonical
  • Milestone set to 5.5
  • Resolution duplicate deleted
  • Status changed from closed to reopened
  • Summary changed from Hello, I found the problem with permalink on the site in the latest version of WordPress. to Redirect paged requests for non-paginated posts to avoid duplicate content

Reopening, let's fix this as a standalone issue, as #28081 is slightly different.

#5 @SergeyBiryukov
3 months ago

  • Owner set to SergeyBiryukov
  • Status changed from reopened to accepted

#6 @SergeyBiryukov
3 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 47727:

Canonical: Redirect paged requests for non-paginated posts to the post permalink.

This avoids displaying duplicate content of the same post under different URLs and ensures the canonical URL is correct.

Previously, requests for invalid page numbers were only redirected to the post permalink if the post was actually paginated using the <!--nextpage--> marker.

Follow-up to [34492].

Props jeremyfelt, prografika, sachit.tandukar, subrataemfluence, hronak, ekatherine, henry.wright, chesio, dd32, SergeyBiryukov.
Fixes #40773. See #45337, #28081, #11694.

#7 @SergeyBiryukov
3 months ago

#44587 was marked as a duplicate.

#8 @SergeyBiryukov
3 months ago

In 47760:

Canonical: Redirect paged requests for a static page assigned as the "Posts page".

This avoids displaying duplicate content of the home page under different URLs with appended page numbers.

This change only affects the <!--nextpage--> pagination (page query variable) and not the regular multiple posts pagination (paged query variable).

The posts page does not support the <!--nextpage--> pagination, so requests for invalid page numbers should be redirected to the page permalink, applying the logic previously implemented for single posts or pages.

Follow-up to [34492], [47727].

Props jeremyfelt, sachit.tandukar, SergeyBiryukov.
Fixes #45337. See #40773, #28081, #11694.

#9 @SergeyBiryukov
3 months ago

In 47761:

Canonical: Only redirect non-existing page requests to the post permalink if the post is found.

Follow-up to [47760].

See #45337, #40773, #28081, #11694.

#10 @SergeyBiryukov
3 months ago

In 47781:

Tests: Give canonical test fixtures for paginated content more descriptive names.

Follow-up to [47727].

See #28081, #40773, #45337.

#11 @SergeyBiryukov
3 months ago

#50192 was marked as a duplicate.

Note: See TracTickets for help on using tickets.