Make WordPress Core

Opened 10 years ago

Last modified 3 days 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 needs-refresh needs-unit-tests
Focuses: Cc:


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

Download all attachments as: .zip

Change History (30)

#1 @Denis-de-Bernardy
10 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.


#2 @rob1n
10 years ago

  • Milestone changed from 2.2.1 to 2.2.2

#3 @markjaquith
10 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.

#4 @JeremyVisser
10 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

#6 @Denis-de-Bernardy
9 years ago

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

#7 @thee17
9 years ago

  • Milestone changed from 2.5 to 2.6

#8 @Denis-de-Bernardy
8 years ago

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

#9 @Denis-de-Bernardy
8 years ago

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

#10 @westi
8 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.

7 years ago

#11 @mdawaffe
7 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.

#12 @mdawaffe
7 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 :)

#13 @mdawaffe
7 years ago

  • Keywords has-patch added

#14 @dd32
7 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?

#16 @dd32
7 years ago

See Also: #15140

#17 @SergeyBiryukov
6 years ago

  • Keywords needs-refresh added

Related: #9825

#18 @SergeyBiryukov
6 years ago

  • Keywords needs-refresh removed

6 years ago

#19 @SergeyBiryukov
6 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).

#20 @dd32
6 years ago

Closed #18318 as a Duplicate

#21 @varun21
6 years ago

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

#22 @varun21
6 years ago

  • Cc varun21 added

#23 @SergeyBiryukov
5 years ago

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

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

#24 @SergeyBiryukov
4 years ago

#25989 was marked as a duplicate.

#25 @TwanVermeulen
3 years ago

Can anyone tell when this enhancement will be implemented?

#26 @swissspidy
21 months ago

  • Keywords needs-refresh needs-unit-tests added

#27 @swissspidy
14 months ago

#34489 was marked as a duplicate.

This ticket was mentioned in Slack in #polyglots by sergey. View the logs.

3 days ago

Note: See TracTickets for help on using tickets.