WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#29997 closed defect (bug) (invalid)

Custom permalink free text same of category base

Reported by: Murphz Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.0
Component: Permalinks Keywords:
Focuses: Cc:

Description

I'm using "/blog/%category%/%postname%" as custom permalink for posts.

I've noticed that if I use blog as the categories base text, all the posts will get a 404 error. If I change "blog" in categories base text, everything's ok.

I wanted to use /blog for posts and for categories too, something like:
/blog/cat1/article1
/blog/cat1

But It's not possible to have the same initial text (if a different one is used, everything's fine) as it raise the 404 error for all posts.

Hope its clear..

Thanks!

Change History (1)

#1 @DrewAPicture
6 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Hi Murphz, thanks for the report and welcome to Trac :)

I can confirm the same behavior, though this is not a bug. The reason you're getting 404s on posts when using 'blog' as the category base in addition to the custom permastruct, is that the rewrite is matching for categories over posts.

In other words, you get a 404 for this:
example.com/blog/category-name/example-post-permalink

and a category archive listing for this:
example.com/blog/category-name/

It's possible to handle multiple routing like this through the same rewrite endpoint, but it requires filtering rewrites and definitely falls outside the scope of what core will handle for you.

Note: See TracTickets for help on using tickets.