Make WordPress Core

Opened 5 years ago

Last modified 3 years 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:


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
5 years ago

  • Component changed from General to Posts, Post Types

#3 @swissspidy
5 years ago

  • Version trunk deleted

#4 @Presskopp
5 years ago

Also related: #37251

Version 0, edited 5 years ago by Presskopp (next)
Note: See TracTickets for help on using tickets.