WordPress.org

Make WordPress Core

Opened 7 years ago

Last modified 5 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
Milestone: Future Release Priority: normal
Severity: normal Version: 2.2
Component: Canonical Keywords: has-patch
Focuses: Cc:

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 4 years ago.
4328.patch (1.2 KB) - added by SergeyBiryukov 3 years ago.

Download all attachments as: .zip

Change History (26)

comment:1 Denis-de-Bernardy7 years ago

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.

comment:2 rob1n7 years ago

  • Milestone changed from 2.2.1 to 2.2.2

comment:3 markjaquith7 years ago

  • 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.

comment:4 JeremyVisser7 years ago

  • 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

comment:6 Denis-de-Bernardy6 years ago

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

comment:7 thee176 years ago

  • Milestone changed from 2.5 to 2.6

comment:8 Denis-de-Bernardy5 years ago

  • Component changed from General to Permalinks
  • Owner changed from anonymous to ryan

comment:9 Denis-de-Bernardy5 years ago

  • Component changed from Permalinks to Canonical
  • Owner changed from ryan to markjaquith

comment:10 westi4 years ago

  • 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.

mdawaffe4 years ago

comment:11 mdawaffe4 years ago

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:12 mdawaffe4 years ago

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 :)

comment:13 mdawaffe4 years ago

  • Keywords has-patch added

comment:14 dd324 years ago

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?

comment:16 dd323 years ago

See Also: #15140

comment:17 SergeyBiryukov3 years ago

  • Keywords needs-refresh added

Related: #9825

comment:18 SergeyBiryukov3 years ago

  • Keywords needs-refresh removed

SergeyBiryukov3 years ago

comment:19 SergeyBiryukov3 years ago

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).

comment:20 dd323 years ago

Closed #18318 as a Duplicate

comment:21 varun213 years ago

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

comment:22 varun213 years ago

  • Cc varun21 added

comment:23 SergeyBiryukov2 years ago

Just stumbled upon this once again. I thought that _wp_old_slug works for pages as well.

Last edited 2 years ago by SergeyBiryukov (previous) (diff)

comment:24 SergeyBiryukov5 months ago

#25989 was marked as a duplicate.

Note: See TracTickets for help on using tickets.