cancel
Showing results for 
Search instead for 
Did you mean: 

http.changeSite with path reset to "/"

paulshore
New Contributor

http.changeSite with path reset to "/"

I need to do a http.changeSite to a new url, but I need to reset the path to "/".

 

I match the current path and site in the traffic script

 

if ( ($host = "test.com/" ) &&

     ($path == "/apps" ) ) {

          http.changeSite( "https://test2.com/" );

}

 

However I end up on "https://test2.com/apps",  how do I reset the path to "/" on a redirect?

 

Thanks

 

Paul

6 REPLIES 6
pwallace
Community Manager

Re: http.changeSite with path reset to "/"

You might try http.redirect( "https://test2.com/" ); which sends a HTTP 302 temporary redirect response, and can give you control over the exact destination URL?

 

There is a short article here on changeSite() here, but it does not give much detail on redirect():

https://community.pulsesecure.net/t5/Pulse-Secure-vADC/HowTo-Redirect-HTTP-clients/ta-p/33130

 

For other readers who are not familar with the power of TrafficScript, the latest reference guide is here:

https://www-prev.pulsesecure.net/download/techpubs/current/1682/Pulse-vADC-Solutions/Pulse-Virtual-T...

 

paulshore
New Contributor

Re: http.changeSite with path reset to "/"

I also tried http.redirect( "https://test2.com/" ); but still ended up with the /apps path.

pwallace
Community Manager

Re: http.changeSite with path reset to "/"

It may also help to write some debug info to the log file to see what is going on: 

 

$host = ...

$path = ...

log.info( "$Host=" . $host . " $Path=" . $path );

 

paulshore
New Contributor

Re: http.changeSite with path reset to "/"

Given the redirect/change site actually happens, I would say that the values for $path and $host match exactly what is in the if statement - no need to log them.

 

I need a way to reset the redirected path.  I have tried adding this to the code within the if statement before the call to http.changeSite or http.redirect, but still goes to /apps on the redirected site.

 

http.setPath( "/" );

 

paulshore
New Contributor

Re: http.changeSite with path reset to "/"

Looks like something was caching on my firefox, tried firefox and chrome on another desktop and it's working fine.

 

Thanks for you help

 

Paul

pwallace
Community Manager

Re: http.changeSite with path reset to "/"

ok great - can you confirm the final version of the script you are using? We can mark as a solution!