Jump to content

Page Path History -module and moving a whole subtree


lpa
 Share

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?

Link to comment
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
Link to comment
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. 

Link to comment
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.

Link to comment
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. 

 

Link to comment
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!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...