Showing results for 
Search instead for 
Did you mean: 

HowTo: Redirect HTTP clients

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


Collected Tech Tips: TrafficScript examples

Version history
Revision #:
1 of 1
Last update:
‎06-10-2015 09:32:AM
Updated by: