Sun Java System Web Server 7.0 Administrator's Guide

Setting up URL Redirection

URL redirection allows you to redirect document requests for one HTTP URL to another HTTP URL. Forwarding URLs or redirection is a method for the server to tell a user that a URL has changed (for example, because you have moved files to another directory or server). You can also 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 a 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:

  1. Click Configurations tab and select the configuration from the configuration list.

  2. Click Virtual Servers sub tab and select the virtual server from the virtual server list.

  3. Click on Content Handling sub tab and URL Redirects sub tab.

  4. Click on New button to add a new URL redirect rule.

  5. Provide necessary values for fields described in . Click on Ok button. You may need to click on Deploy button 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

Parameter

Description

From URL

URL from which the requests should be redirected. All HTTP requests to this URL will be redirected to the URL specified in the Target URL. 

Target URL

URL to which the requests should be redirected. All HTTP requests from the URL specified in the From URL will be redirected to this URL. 

URL Type

Fixed. Enabled/Disabled. Fixed URLs are static URLs like a link to an HTML page. Non-Fixed URLs are dynamic URLs with request parameters or URLs with just prefixes.


Note –

Using CLI

For adding 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).