Index: openacs-4/packages/redirect/redirect.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/redirect/redirect.info,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/redirect/redirect.info 29 Sep 2003 13:17:37 -0000 1.1 @@ -0,0 +1,31 @@ + + + + + Redirect + Redirects + f + f + + + Tilmann Singer + Simple package that redirects from the URL it is mounted on to another URL. + 2003-09-29 + Simple package that redirects from the URL it is mounted on to another URL. Useful when you have moved content to a new place but don't want old links to break. + +The new URL can be entered with a parameter setting. + +Note that it does not pass through requests to another application, e.g. one that is running on apache. Use the gatekeeper package for this. + + + + + + + + + + + + + Index: openacs-4/packages/redirect/www/index.vuh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/redirect/www/index.vuh,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/redirect/www/index.vuh 29 Sep 2003 13:17:37 -0000 1.1 @@ -0,0 +1,58 @@ +ad_page_contract { + + Redirect to the NewURL parameter setting of this package. + +} + + +set new_url [parameter::get -parameter NewURL] + +if { [empty_string_p $new_url] } { + ad_return_error "NewURL not set" "The NewURL parameter of this redirect package is not set, so a redirect is not possible. Please set the parameter in the site-map." + ad_script_abort +} + +if { !([util_complete_url_p $new_url] || [util_absolute_path_p $new_url]) } { + ad_return_error "NewURL must be an absolute path" "The NewURL parameter must either start with '/' or with a protocol and server, like 'http://myserver.com/'." + ad_script_abort +} + +# transform url to an absolute path - copied from ad_returnredirect +if { ![util_complete_url_p $new_url]} { + # /foo/bar.tcl style - prepend the current location: + set new_url [util_current_location]$new_url +} + +if { [parameter::get -parameter PreservePathRemainings -default 1] } { + # append remaining path elements to new url + set new_url "[string trimright $new_url /]/[ad_conn path_info]" + if { ![empty_string_p [ad_conn query]] } { + append new_url "?[ad_conn query]" + } +} + +ns_set put [ns_conn outputheaders] Location $new_url + +if { [parameter::get -parameter PermanentRedirect -default 1] } { + # permanent redirect + ns_return 301 text/html " +Redirection + +

Redirection

+The requested URL has moved here permanently. + + +" +} else { + # non-permanent redirect + ns_return 302 text/html " +Redirection + +

Redirection

+The requested URL has moved here. + + +" +} + +return Index: openacs-4/packages/redirect/www/doc/index.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/redirect/www/doc/index.html,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/redirect/www/doc/index.html 29 Sep 2003 13:17:37 -0000 1.1 @@ -0,0 +1,76 @@ + + + + +Documentation for the Redirect package + + + +

Documentation for the Redirect package

+ +

Introduction

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

Pass Through of Requests

+ +This package does not pass through http requests - see the gatekeeper +package for this functionality. (Maybe gatekeeper will be merged into +this package some day though.) + + +
+
+Last modified: Mon Sep 29 13:10:03 GMT 2003 +