[Zope] URL redirection, maintaining arbitrary path?

Ian Beatty beatty at physics.umass.edu
Mon Oct 6 13:49:46 EDT 2003


On 2003-10-06 11:19, Florian Lindner is reputed to have said:

>> 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

Works like a charm. Thanks!

..Ian

-- --- -- --- -- --- -- --- -- --- -- --- -- --- -- --- -- --- --
Dr. Ian Beatty                           beatty at physics.umass.edu
Physics Education Research                    voice: 413.545.9483
Department of Physics                           fax: 413.545.4884
Univ. of Massachusetts           http://umperg.physics.umass.edu/
Amherst, MA 01003-4525 USA
-- --- -- --- -- --- -- --- -- --- -- --- -- --- -- --- -- --- --





More information about the Zope mailing list