Opened 8 years ago
Last modified 21 months ago
#37812 new defect (bug)
404 when using a numeric slug and /%category%/ base
Reported by: | mikejolley | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | |
Component: | Permalinks | Keywords: | needs-unit-tests needs-patch |
Focuses: | Cc: |
Description
To reproduce:
- Create a top and sublevel category. Lets say Parent > Child
- In permalink settings, set custom permalink structure /%category%/%postname%/
- Create a post with slug 12345 and assign to category "child"
- View post.
There is a 404.
Tested in 4.6 only. No other plugins active.
Change History (5)
#1
@
8 years ago
- Keywords needs-unit-tests needs-patch added
- Milestone changed from Awaiting Review to Future Release
- Version 4.6 deleted
#2
@
8 years ago
#5305 addressed the issue where the permalink of a post could conflict with a date archive if the post had a numeric permalink. So it's similar to this issue, but not related to dates - it has to do with pagination. It's likely that we could institute a similar sort of suffixing to what we did in #5305.
#3
@
8 years ago
@boonebgorges @swissspidy I have had this issue for a while, exactly as @mikejolley explained. While the pages no longer 404 for normal traffic, they do 404 for Facebook's crawler and for Pinterest's crawler. I'm not sure if the initial error was fixed in WP, but if it was, it seems the error might still exist outside of normal browser traffic.
Hope this is helpful.
Confirmed, also on older installs.
With a non-numerical slug the matched query is
category_name=parent%2Fchild&name=test&page=
, whereas with a numerical slug it iscategory_name=parent&name=child&page=12345
.The rewrite rule for the
/%category%/%postname%/
structure is(.+?)/([^/]+)(?:/([0-9]+))?/?$
(category_name=$matches[1]&name=$matches[2]&page=$matches[3]
).Looks like numerical slugs should be forbidden in that case and suffixed (e.g.
1234-2
). @boonebgorges didn't you fix something similar recently? Can't find the ticket.