vADC Docs

HowTo: Redirect HTTP clients

by on ‎02-25-2013 02:17 AM (4,105 Views)

The TrafficScript function http.changeSite() makes it easy to redirect clients from one domain to another.  You can also use it to reliably redirect clients from http to https (or https to http), or from one document tree on a website (e.g. /products) to another (e.g /sales).

# Example: Redirect client from to

if( geo.getCountryCode( request.getRemoteIP() ) == "GB" ) {

  http.changeSite( "" );


# Example: Force client to https (assuming this rule is attached to an HTTP virtual server)

http.changeSite( "https://" . http.getHostHeader() );

# Example: move client from one tree to another

$path = http.getPath();

if( string.startsWith( $path, "/products" ) ) http.changeSite( http.getHostHeader(). "/sales" );

For more fine-grained control of HTTP redirects, you can also use the http.redirect() function.

Read more

by slicerpro
on ‎02-20-2017 09:33 AM

This is what I'm preeping to put in:


$request = http.getRequest();
if( string.contains( http.getheader( "Host" ), "" ) ){
http.changeSite( "https://" . http.getHostHeader() );