Opened 19 months ago
Last modified 18 months ago
#57858 new defect (bug)
If permalink structure is set to /%category%/%postname% , WordPress will match a /0/ path as a category archive
Reported by: | krdevio | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 6.1.1 |
Component: | Rewrite Rules | Keywords: | has-testing-info needs-testing needs-patch |
Focuses: | Cc: |
Description
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:
- Spin up a fresh WordPress
- Go to Settings > Permalinks > Permalink Structure > Custom Structure
- Set the Custom Structure to: /%category%/%postname%
- 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/
Attachments (2)
Change History (9)
#2
follow-up:
↓ 3
@
18 months ago
I am getting proper 404 for all the cases you mentioned except below,
example.com/0/
will properly resolve to the home page
and does not give 404
/0/some-post-name
will properly resolve to some-post-name
page regardless of in which category it belongs
#3
in reply to:
↑ 2
@
18 months ago
Replying to kalpeshh:
I am getting proper 404 for all the cases you mentioned except below,
example.com/0/
will properly resolve to thehome page
and does not give 404
/0/some-post-name
will properly resolve tosome-post-name
page regardless of in which category it belongs
I just retested, you know what you are correct. My apologies My permalink settings were not exactly
/%category%/%postname%
, and testing that it was fine as you said.
With that said it might still be a bug: The exact permalink setting I had was /%category%/%postname%.html
(.html at the end). I guess adding the .html
at the end causes /0/ to match as mentioned initially.
#4
@
18 months ago
Welcome to core track, thanks for creating ticket
I have tried to reproduce this issue and you are right it does resolve to category archive
The link example.com/wp-content/0/ will not return a 404, and resolve to category archive template.
Test Report
Env
WordPress 6.1.1
Chrome Version 110.0.5481.177 (Official Build) (arm64)
MacOS Monterey
Theme: Twenty Twenty Three
Steps to test
- The exact permalink setting I had was /%category%/%postname%.html
#5
@
18 months ago
Welcome to core track, thanks for creating ticket
I have tried to reproduce this issue and you are right it does resolve to category archive when you adding permalink /%category%/%postname%.html . if you add permalink /%category%/%postname%/html like this it will redirect into 404 page https://prnt.sc/x_kBuK_lVqFK.
Env
WordPress 6.1.1
Chrome 110.0.5481.177
MacBook Air M1
Theme: Twenty Twenty Three
Gutenberg Editor
Hi @krdevio, welcome to Trac and thanks for opening this ticket.
I'm just adding some keywords to help get this ticket some more attention. 🙂
Related/Semi-duplicate: