URL redirection enables you to redirect document requests from one HTTP URL to another HTTP URL. Forwarding URLs, also known as redirection, is a method in which the server tells a user that a URL has changed. URLs may change when files are moved to another directory or server. You can use redirection to seamlessly send request for a document on one server to a document on another server.
For example, if you forward http://www.sun.com/info/movies to the prefix film.sun.com, the URL http://www.sun.com/info/movies redirects to http://film.sun.com/info/movies.
Sometimes you may want to redirect requests for all the documents in one sub-directory to a specific URL. For example, if you had to remove a directory because it was causing too much traffic, or because the documents were no longer to be served for any reason, you can direct a request for any one the documents to a page explaining why the documents were no longer available. For example, a prefix on /info/movies can be redirected to http://www.sun.com/explain.html.
You can set URL redirection at the virtual server level.
To configure URL redirection, perform the following steps:
Click the Configurations tab and select the configuration from the configuration list.
Click the Virtual Servers sub tab and select the virtual server from the virtual server list.
Click the Content Handling sub tab and then the URL Redirects sub tab.
Click New to add a new URL redirect rule.
Provide necessary values for the fields. Click OK . Click Deploy for the configuration if needed.
The following table describes the parameters required while adding a new URL Redirect rule.Table 9–1 URL redirect Parameters
URI Prefix — URI from which the requests should be redirected. All HTTP requests to this URI pattern will be redirected to the URL specified by the Target URL.
Condition — Instead of providing a URI prefix as the source, you can also use regular expression in the condition text field. For example, if you need to redirect requests to a particular URL, if the browser is Mozilla, then type $browser = “Mozilla” in the condition field.
Another valid example is $browser =~ “MSIE”.
The Web Server includes a set of variables predefined by the server, as well as the capability for you to define custom variables. In our example, browser is a pre-defined variable. For a list of available pre-defined variables, see Predefined Variables in Oracle iPlanet Web Server 7.0.9 Administrator’s Configuration File Reference.
You can define custom variables in the server.xml file using the variables element and then refer to those variables from this condition text.
Administration Console supports only <If> tag with redirect SAF for NameTrans directive with all the variables, expression literals, expression functions and expression operators.
For more information on variables, operators and expression, see the Administrator's Configuration File Reference Guide.
To add a new URL redirection rule through CLI, execute the following command.
wadm> create-url-redirect --user=admin --password-file=admin.pwd --host=serverhost --port=8989 --no-ssl --config=config1 --vs=config1_vs_1 --uri-prefix=/redirect --target-url=http://www.cnet.com
See CLI Reference, create-url-redirect(1).