URL redirection, maintaining arbitrary path?
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? Thanks, ..Ian -- --- -- --- -- --- -- --- -- --- -- --- -- --- -- --- -- --- -- Dr. Ian Beatty beatty@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 -- --- -- --- -- --- -- --- -- --- -- --- -- --- -- --- -- --- --
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
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@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 -- --- -- --- -- --- -- --- -- --- -- --- -- --- -- --- -- --- --
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.
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)
Tomorrow I think I'll be adding this functionality to MovedObject. It redirects and gives the proper HTTP status code, so as to inform search engines and whatnot. The current release doesn't do subpaths, but the next one will. There's also Rewriter and Redirector, but I never did figure out how they work, which is why I wrote MovedObject. Yes, it really was easier to write a new product than figure out the existing ones, at least in this case. --jcc -- "Code generators follow the 80/20 rule. They solve most of the problems, but not all of the problems. There are always features and edge cases that will need hand-coding. Even if code generation could build 100 percent of the application, there will still be an endless supply of boring meetings about feature design." (http://www.devx.com/java/editorial/15511)
J Cameron Cooper wrote:
There's also Rewriter and Redirector, but I never did figure out how they work, which is why I wrote MovedObject.
Ooh! I don't know this. I'm using JRedirector, which I found quite workable and not cryptic: http://www.dataflake.org/software/jredirector/ -- Jean Jordaan http://www.upfrontsystems.co.za
participants (4)
-
Florian Lindner -
Ian Beatty -
J Cameron Cooper -
Jean Jordaan