WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 6 months ago

#37832 new defect (bug)

Using ?p=xxx on a posts page with an invalid post ID does not return a 404 status

Reported by: smerriman Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords:
Focuses: Cc:
PR Number:

Description

Steps to replicate:

  • Create a page and set it as the posts page.
  • Visit this page with ?p=123456 (an invalid ID) added.

WordPress will return whatever 'no results found' message you have in the theme, but with a 200 status.

The handle_404 function seems to have been set up to always give a 200 status if is_home() returns true. This should not apply if you're overriding the query in some way via the URL.

Somehow many of these URLs have been detected by Google on a site of ours and are being reported as soft 404s. How they were found is one thing, but WordPress should not be returning a 200 status regardless.

Change History (4)

#1 @SergeyBiryukov
3 years ago

  • Component changed from General to Posts, Post Types

#3 @swissspidy
3 years ago

  • Version trunk deleted

#4 @Presskopp
3 years ago

Also related: #37251 plus new one: #37862

Last edited 3 years ago by Presskopp (previous) (diff)
Note: See TracTickets for help on using tickets.