Jump to content
lpa

Page Path History -module and moving a whole subtree

Recommended Posts

I have a need to move a whole subtree of pages at once to another path. I would like the Page Path History -module to take care of the redirection of the old path locations to the new parent. But it seems to me that I have to move every single page individually for the move to register in Page Path History. 

Should this module handle the whole subtree or just the top level? Do I need to move the pages using API for the history to save with the move?

Share this post


Link to post
Share on other sites

Sounds like a classical use case for server redirects. For example, in Apache, assuming your old subtree lived under "example.com/canines/..." and you want to move it to "example.com/dogs/...", here's a simple redirect rule that will do that, while preserving the rest of the path:

RedirectMatch "^/canines/(.*)" "/dogs/$1"

Example shamelessly taken from the Apache manual. Would be trivial in nginx as well. You can do the same thing in your PHP logic, but it will be slightly slower. By using the Apache redirect, the server needn't even bother ProcessWire with the request.

  • Like 2

Share this post


Link to post
Share on other sites

Thank you for the suggestion. I know we could do that and maybe we do. But if we still need to keep something under /canines/, that option won't work. And if the moves of the documents are done by editors, they don't know about or have access to redirect rules in .htaccess. 

Share this post


Link to post
Share on other sites
11 hours ago, lpa said:

But it seems to me that I have to move every single page individually for the move to register in Page Path History.

Are you sure? Page Path History seems to correctly redirect pages after I move a page structure in Page List.

Share this post


Link to post
Share on other sites

Well, it seems to work if I leave the parent of the subtree documents to the old path like this:

Move the subtree under the new parent path2:

/path1/subtree1/article1/ -> /path2/subtree1/article1/

article1 (path: /path1/subtree1/article1/)  is redirected to /path2/subtree1/article1/ if /path1/subtree1/ is not removed. If that is removed, /path1/subtree1/article1/ is shown in the browser address even though the page shown is /path1/subtree1/. And no 404-error is shown even though the page /path1/subtree1/article1/ does not exist any more. 

 

Share this post


Link to post
Share on other sites

Moderator note: this is not a support board for a new module, so I'm moving it to the General Support area of the forum.

The "Modules/Plugins" section of the forum is for dedicated module support threads. If you have a general question regarding ProcessWire, ProcessWire core modules, or "how to do [x] with ProcessWire", you should post it to the General Support area – or if it's a question regarding an existing module, check the "Support Board" link from the modules directory entry for that module and post your question to the linked thread instead.

Thanks!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...