[wp-trac] [WordPress Trac] #27019: Redirect by page slug does not work in permalink structure /%category%/%postname%/

WordPress Trac noreply at wordpress.org
Wed Jul 23 01:37:35 UTC 2014


#27019: Redirect by page slug does not work in permalink structure
/%category%/%postname%/
--------------------------+------------------------------
 Reporter:  dimagsv       |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Permalinks    |     Version:  3.8.1
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by mboynes):

 Replying to [comment:3 dimagsv]:
 > Pages must be the fallback rules in any permalink structure and any url
 structure.

 That's not possible as things stand, and to make it possible would require
 WordPress to do a lot more work to display pages.

 Rewrite rules are analyzed in sequential order in a loop, and once a path
 matches a rewrite rule, it exits the loop. ''However'', there's a special
 condition for verbose rules where it first checks to see if a page exists
 before exiting the loop. Specifically, when you have a
 `/%category%/%postname%/` structure, the path /foo/bar/ could either be
 referring to a page `bar` which has a parent `foo`, or it could refer to
 the post `bar` in the category `foo`. WordPress accounts for this by
 checking to see if the page exists, and if not, it assumes that this is a
 category/post combo. In order for pages to be the fallback rules,
 WordPress would have to check to see if the category exists, the post
 exists, and the post is in the category, before it could rule out the
 category/post rules. While that seems like 3x the effort, it can actually
 be significantly more, since it might require table joins.

 In the end, my contention remains that this is not a bug. If anything,
 it's a feature request for automatic redirects. If WordPress were to have
 such a feature, `redirect_guess_404_permalink()` would not be the way to
 go; we'd want to instead do something like store the old rules, and
 process them for 404s. Personally, I wouldn't want such a feature, as it
 would mean significantly more effort to display 404s, and would make every
 WordPress site more vulnerable to DOS attacks. I'm sure there are plenty
 of people who ''would'' want that feature, so it's a great idea for a
 plugin.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/27019#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list