lpa Posted April 9, 2019 Share Posted April 9, 2019 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 More sharing options...
MoritzLost Posted April 9, 2019 Share Posted April 9, 2019 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. 2 Link to comment Share on other sites More sharing options...
lpa Posted April 9, 2019 Author Share Posted April 9, 2019 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 More sharing options...
Robin S Posted April 9, 2019 Share Posted April 9, 2019 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 More sharing options...
lpa Posted April 10, 2019 Author Share Posted April 10, 2019 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 More sharing options...
teppo Posted April 13, 2019 Share Posted April 13, 2019 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now