[wp-hackers] Changing page permalink structure

Benjamin Lupu benjamin.lupu at gmail.com
Tue Oct 2 15:46:51 UTC 2012

Hi Bryan. We did tests on the 3.4.2 and we didn't have the behaviors you're

- If I have the following URL :
- If I change /page-slug-3/ to /page-slug-ZZZ/ in the Edit Panel, I get a
- If I turn the URL into http://mydomain.com/page-slug-3/, a 301 redirect
is done to http://mydomain.com/page-slug-1/page-slug-2/page-slug-3/(redirect
is based on the page slug). It also works if you have the
following URL :  http://mydomain.com/page-slug-1/page-slug-3/
- So we can say that reparenting is covered unless one of the slugs has
- If you change any slug (parents or the page itself) you get a 404

Do you find the same results ?

@Matthias : danke :-) We did that but for load reasons we finally decided
to use the ID trick (see below) which relies only on WP hooks. However,
there is one case where we're going to use this solution : when a page is
deleted, we'll have a plugin asking for a target for the 301 redirect.


Thx both of you. I believe maybe my mast email to the list didn't make it,
so I repost it here :

Just to let you know that we're still working on this page issue. We have
now a prototype using regular Wordpress hooks and doing the following :

   - First I can add more regarding the current page permalink behavior :
   if you suppress all the parent page slugs from the URL (keeping only the
   final page slug), Wordpress does a 301 redirection to the whole permalink.
   It's the same if you suppress only one parent page slug. However, if you
   modify a parent page slug or the final page slug, you'll have a 404 error.
   - It drove us to try the same solution we have applied for posts :
   introduce the post/page id into the permalink so that even the slug
   changes, a 301 redirection is done based on the id
   - We've managed to have a prototype working based on regular hooks.
   Basically, what it does is to add /[page id]/ at the end of the permalink.
   Based on this id and even the whole URL changes, the plugin manages to
   build the correct 301 redirection to the new permalink. So far tests are

We've planned to release a beta version of a page manager with this feature
in the next few weeks.

2012/10/2 Bryan Petty <bryan at ibaku.net>

> On Tue, Oct 2, 2012 at 7:53 AM, "Matthias P. Würfl" <mpw at taquiri.de>
> wrote:
> > Why not simply keep track of the changes of the URL? Save the old URL to
> a
> > table and search this before giving a 404. Then send 301 instead of 404.
> Actually, I've looked into this more now, and realized that the latest
> version of WordPress does actually redirect appropriately to the new
> page structure when re-parenting happens. Also, I did already know
> that when slugs change, the old one is still saved, and still works
> (and redirects appropriately as well).
> In fact, as long as the last slug in the URL is the current or an
> older slug for a page, it doesn't matter what you specify as the
> parent slugs, WordPress will automatically redirect appropriately,
> even if those parent page slugs never existed.
> So all of this should work perfectly fine already for what Benjamin
> Lupu wants to do.
> Regards,
> Bryan Petty
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

Benjamin Lupu
Email: benjamin.lupu at gmail.com

More information about the wp-hackers mailing list