[Zope] URL redirection, maintaining arbitrary path?

Florian Lindner mailinglists at xgm.de
Mon Oct 6 11:19:29 EDT 2003


Ian Beatty wrote:
> Greetings.
> 
> I'm in the process of porting a website over to Zope/Plone, and find it
> necessary to do some reorganization of my site's URL structure. In order to
> break as few old links as possible, I'd like to put in some redirects. I've
> found information on how to redirect one particular URL, but what I'd like
> to do is this kind of thing: have *any* request of the form
> 
>     http://my.server.com/x/a/b/...
> 
> get redirected to
> 
>     http://my.server.com/x/newPiece/a/b/c
> 
> where the path that comes after "x/" in the original URL (if anything) is
> preserved at the end of the "new" URL. In other words, I'm mapping an entire
> tree of my site to a new location.
> 
> Is this possible? Any suggestions?

Just an idea:

Put a Script named b in my.server.com/x/a/ and use traverse_subpath to 
build your redirection URL.
Pseudo code of script b:

redirect = http://my.server.com/x/newPiece/a/b/c/

for element in traverse_subpath:
   redirect = redirect + "/" + element

REQUEST.RESPONSE.redirect(redirect)

HTH,
Florian




More information about the Zope mailing list