[wp-trac] [WordPress Trac] #57858: If permalink structure is set to /%category%/%postname% , WordPress will match a /0/ path as a category archive

WordPress Trac noreply at wordpress.org
Thu Mar 2 22:30:38 UTC 2023


#57858: If permalink structure is set to /%category%/%postname% , WordPress will
match a /0/ path as a category archive
---------------------------+-----------------------------
 Reporter:  krdevio        |      Owner:  (none)
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Rewrite Rules  |    Version:  6.1.1
 Severity:  normal         |   Keywords:
  Focuses:                 |
---------------------------+-----------------------------
 Issue:

 When the post permalink structure (Settings > Permalinks > Permalink
 Structure > Custom Structure ) is set to /%category%/%postname% , any path
 containing /0/ will be matched as a category archive page.

 eg.
 example.com/wp-content/0/ will not return a 404, and resolve to category
 archive template.
 example.com/wp-includes/0/ will not return a 404 and resolve to category
 archive template.
 example.com/wp-admin/0/ will not return a 404 and resolve to category
 archive template.
 example.com/some-post-name/0/ will resolve to some-post-name
 example.com/0/ will properly resolve to the site_url, but still wont 404

 Setting the permalink to anything but that, eg. /%author_name%/%postname%
 it will properly 404.

 I'm guessing somewhere in the permalink structure, 0 is seen as a valid
 category and not empty/null.


 Steps to reproduce:
 1. Spin up a fresh WordPress
 2. Go to Settings > Permalinks > Permalink Structure > Custom Structure
 3. Set the Custom Structure to: /%category%/%postname%
 4. Visit one of the example URLs above.


 We found this issue as we noticed Google was indexing a page like
 example.com/wp-content/uploads/2011/0/

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57858>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list