Opened 6 years ago

Last modified 13 months ago

#4328 new enhancement

Redirect Old Slugs feature needs to redirect slugs for pages, not just posts, and redirect old permalink structure

Reported by: Denis-de-Bernardy Owned by: markjaquith
Priority: normal Milestone: Future Release
Component: Canonical Version: 2.2
Severity: normal Keywords: has-patch
Cc: varun21

Description

Create a page, browse to it, edit it, change its slug, WP redirects to the old page's slug and serves a 404. Wasn't WP 2.1 or WP 2.2 supposed to make the redirect old slug feature built-in?

Along the same lines, it would be sweet if instead of simply redirect old slugs, WP would redirect old urls. When the date changes, when the page parent changes, or when the permalink structure changes, the url changes but neither of WP, the redirect old slug plugin, the permalink redirect plugin, or anything else catches this.

Attachments (2)

4328.diff (1.1 KB) - added by mdawaffe 3 years ago.
4328.patch (1.2 KB) - added by SergeyBiryukov 2 years ago.

Download all attachments as: .zip

Change History (25)

adding to the above, the workflow would be:

on post save, cache the url in a custom field. if url is different, append previous value to the old urls.

on permalink structure change, do the above for every post and page on the site.

extra benefit: scanning for which post is requested can be simplified in many cases to something like: select from posts inner join postmeta where url_cache.

D.

  • Milestone changed from 2.2.1 to 2.2.2
  • Milestone changed from 2.2.2 to 2.4
  • Type changed from defect to enhancement

WP 2.1+ has it built in, but it only works with posts (by design). I just tested it on Trunk and 2.2, and it works as expected for posts.

Having it work for pages or having it track more than slug changes would be a new feature, so it doesn't belong in a 2.2.x release.

  • Summary changed from redirect old slug feature is very broken to Redirect Old Slugs feature needs to redirect slugs for pages, not just posts, and redirect old permalink structure

Any odds we'll see this in an early 2.5.x?

  • Milestone changed from 2.5 to 2.6
  • Component changed from General to Permalinks
  • Owner changed from anonymous to ryan
  • Component changed from Permalinks to Canonical
  • Owner changed from ryan to markjaquith
  • Milestone changed from 2.9 to Future Release

As we are now feature frozen it is too late to include this into 2.9.

Moving to Future Release as there is currently no patch.

4328.diff turns old slug redirect on for pages.

Two line patch seems to work fine... what are the edge cases?

Works with top level pages and child pages.

comment:ticket:3202:2 by markjaquith says

Only works on posts. There doesn't seem to be a clean way of recognizing failed Page attempts... of course there is always my "Page Links To" plugin to take care of that. ;-)

Quote is 3 years old. Either there are some cases I didn't think of or it's no longer true :)

  • Keywords has-patch added

The only side effect to this would be creating a page AND post of the same name, and then renaming one or both of them.. It might not have the intended path to follow through?

See Also: #15140

  • Keywords needs-refresh added

Related: #9825

  • Keywords needs-refresh removed

According to Denis' comment on #15140:

If both the slug and the parent change, the redirect doesn't work.

However it seems to be working on current trunk (with the refreshed patch).

Closed #18318 as a Duplicate

When are we expecting this to land into the production distro? Tnx.

  • Cc varun21 added

Just stumbled upon this once again. I had the impression that _wp_old_slug works for both posts and pages.

Version 0, edited 13 months ago by SergeyBiryukov (next)
Note: See TracTickets for help on using tickets.