Forum Discussion

Sam_D_'s avatar
Sam_D_
Icon for Altostratus rankAltostratus
Oct 11, 2019

iRules uses regsub to do URL conversions

I'd like to automatically convert URLs, i.e

I've tried following code snippet in TCL

set loc "https://sc-uat.ct.example.com/sc/"
 
set envs(dev) "test"
set envs(uat) "beta"
set envs(qa) "demo"
 
puts $envs(uat)
regsub -nocase {://.+-(.+).ct.example.com} $loc {://inv[$envs(\1)].example.com} hostname
 
puts "new location = $hostname"

But the result is: new location = https://inv[$envs(uat)].example.com/sc/ It seems that [$envs(uat)] is NOT eval-ed further.

 

Any hints will be appreciated. Thanks in advance