KimiLi_147173
Nov 27, 2017Nimbostratus
Want to rewrite part of host
Hi guys, I'm still new to iRules, I wonder that if it is possible that an iRule can rewrite part of the host instead of all of it.
I mean like, if a client request a host like "123.aaa.com/888/", he will be redirected to the "123.bbb.com/888/", I just want to rewrite the "aaa.com" part, which is when requests to host like "xxx.aaa.com/xxx/" I'd like it to be redirected to "xxx.bbb.com/xxx/", is this possible?
Thanks guys.
If string position is known then you can use
function to grep value like below.getfield
set hostname [getfield [HTTP::host] "." 1] If the URL is xxx.aaa.bbb.com, then getfield command will grep value of 1st position xxx set hostname1 [getfield [HTTP::host] "." 2] If the URL is xxx.aaa.bbb.com, then getfield command will grep value of 2nd position aaa
Refer below link. Hope it will be helpful.