Hi @ all,
once again a question about TrafficScript ...
I want to define a rule with multiple terms but it should only be 1 rule ...
Here´s the situation:
My url is http://test.com,
my Url-Path is "path1",
my selected Pool is "pool-1"
the difficulty here is, that the Backend-Server (pool-1) don´t listen at "path1" , only at "path2", so I´ve to rewrite "path1" in "path2"
Here´s my rule, unfortunately it doesn´t work.
$path = http.getpath();
if( http.getheader( "host" ) == "http://test.com"
&& $path == "/path1 " ){
$path = string.regexsub( $path, "path1 ", "path2" );
http.setpath( $path );
pool.use( "pool-1" );
}
At the end it should be like this:
I call "http://test.com/path1" and the TrafficManager routed it to "pool1" and changed "path1" into "path2".
Can somebody help me here or have an idea where´s my mistake?
Regards,
Michael
Solved! Go to Solution.
Hi Michael,
I would have written your rule like this:
The Host header does not contain the URL scheme, and you have a trailing space character at the end of your "/path1 " string in the condition too.
Cheers
Hi Michael,
I've noticed a white space in your script inside regexsub statement.
Is it an error in copy/paste?
Stefano
Hi Stefano,
yes, thia was an copy/paste error ... here´s the content again:
$path = http.getpath();
if( http.getheader( "host" ) == "http://test.com"
&& $path == "/path1 " ){
$path = string.regexsub( $path, "path1", "path2" );
http.setpath( $path );
pool.use( "pool-1" );
}
Ok, have you tried to check what is returned by "getPath"?
You can also try to substitute "$path == "/path1 "" with string.startWithI($path, "/path1")
Now I've got to go.
Bye
Stefano
Hi Michael,
I would have written your rule like this:
The Host header does not contain the URL scheme, and you have a trailing space character at the end of your "/path1 " string in the condition too.
Cheers
Hello Sameh,
thanks fior you answer.
I´ll check this and come back to you.
Regards