Inspired by the recent endeavour to change a URL on the openacs.org site without breaking old links, I've written a small package called Redirect that could be used to facilitate this task. I pasted its documentation below which should make it more than clear what it does.
My question is, where should I commit it? Any objections against adding it to openacs-4 HEAD? Should it even be a core package?
From it's doc:
This is a simple package that sends a redirect to another location, depending on its parameter settings. It is intended for the situation when you moved parts of your site to another location in order to reorganise your site, but don't want old links such as users bookmarks, links from remote sites, external search engine hits etc. to break.
Usage
Mount it at the old location using the openacs site-map, and set its NewURL parameter to the new location. E.g. when you moved a tree of your site from '/some/old/path/' to '/newurl/' then mount an instance of redirect at '/some/old/path/', and set its NewURL parameter to '/newurl/'.
Parameters
NewURL
The URL to redirect to. E.g. /some/path/ or http://anotherserver.com/some/path/.
Relative paths like 'some/other/path/' are not possible.
PreservePathRemainings
Wether to preserve the remainings of the requested path, e.g. if set to true then the redirect /some/old/path/bla/bla goes to /some/new/path/bla/bla, otherwise it goes to /some/new/path/, regardless of what followed the request. In most cases makes sense to leave set to true.
This also includes query parameters, so that a request for '/some/old/path/bla?item_id=100' gets redirected to '/newurl/bla?item_id=100' when set to true.
PermanentRedirect
Indicate to the requesting browser that this is a permanent redirect. The browser might react by updating a bookmark to the new url for example. Leave set to true if unsure.
Note that this results in different http status codes. A permanent redirect is http status 301, a non-permanent is 302. See general http documentation for more info about the consequences.