CTX110261 - URL Redirection Using Content Switching

CTX110261 - URL Redirection Using Content Switching

This document was published at: http://support.citrix.com/article/CTX110261

Document ID: CTX110261, Created on: Aug 21, 2006, Updated: Aug 23, 2006

Products: Citrix NetScaler Application Delivery Software 6.1, Citrix NetScaler Application Delivery Software 6.0


There are times when the NetScaler needs to be setup to handle URL redirection. URL Redirection is a technique on the World Wide Web for making a Web page auto redirect under many URLs. This article describes how to configure the NetScaler to direct all incoming requests for the Web root “/” to a particular homepage, but the technique may be adapted (using alternate policies) to configure redirection of arbitrary requests to arbitrary Web pages.


NetScaler version 6.0 or later.


In order to get the NetScaler to redirect a URL to another URL it requires the use of Content Switching virtual server, Content Switching policy, the default content switch policy, two load balancing virtual servers and one dummy service bound to a dummy server. One load balancing virtual server is a “real” virtual server, in the UP state that has the services bound to it, and the other virtual server is a dummy virtual server that is in the DOWN or DISABLED state which is configured for –URLRedirect. This dummy virtual server must also be bound to a dummy service. The Content Switch uses two policies, one that matches what the Uniform Resource Identifier (URI) that the users are typing in and a default policy if the match fails. The Content Switch policies must be bound to the appropriate Target load balanced virtual server for the intended behavior to occur.

The client request, for example http://www.citrix.com/, is first sent to the Content Switch virtual server where it will match some policy like “REQ.HTTP.URL == /”. Upon matching the request is switched to the dummy LB virtual server. Because the dummy virtual server is in the DOWN state, it uses the –URLRedirect parameter, for example http://www.citrix.com/support, to respond to the client with the appropriate HTTP 302 redirect. The client sends a new GET request containing the complete URI specified by the –URLRedirect parameter. The bound policy will not be hit this time, so will fall through to the default policy which will direct the traffic to the “real” load balancing servers, with the complete URI.


1. First create a dummy server and service that will be used to for the dummy virtual server, using the IP address

add server dummy-server

add service dummy-service dummy-server HTTP 80

Note: Using the GUI, the same can be achieved by clearing the “directly addressable” check box.

2. Create two load balanced virtual servers; one for the real virtual server and the other for the dummy virtual server. No IP address should be specified when creating these LB vservers (again, clear “directly addressable if using the GUI”).

add lb vserver Vserver-LB-UP HTTP

add lb vserver Dummy-LB-DOWN HTTP -state DISABLED

3. Bind actual services to the real load balancing virtual server. In this case Vserver-LB-UP.

bind lb vserver Vserver-LB-UP Service1 -weight 1

bind lb vserver Vserver-LB-UP Service2 -weight 1

4. Bind the dummy service to the dummy virtual server and set the dummy virtual server with the URL that should be specified in the 302 redirect response.

bind lb vserver Dummy-LB-DOWN dummy-service -weight 1

set vserver Dummy-LB-DOWN -redirectURL http:/www.citrix.com/support

5. Create a Content Switch policy that matches the URI “/” at the end.

add cs policy CS-redirect -rule "REQ.HTTP.URL == /"

Note: “/*” is not a sensible option as it will match everything after http://www.citrix.com/, which will result in an infinite loop of redirects.

6. Create a Content Switch virtual server. This virtual server address will need to be resolvable for the URL that the users are using in the browsers.

add cs vserver CS-Redirect-VIP HTTP 80

7. Bind the Content Switch policy and the default policy to the Content Switch virtual server with the appropriate load balance virtual servers.

bind cs vserver CS-Redirect-VIP Dummy-LB-DOWN -policyName CS-redirect

bind cs vserver CS-Redirect-VIP Vserver-LB-UP

More Information

For more information on URL redirection, refer to CTX108946 – Description of the Redirect URL Feature.

Application Networking: 
Powered by Drupal