Forum Discussion

KimiLi_147173's avatar
KimiLi_147173
Icon for Nimbostratus rankNimbostratus
Nov 27, 2017

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/"...
  • Samir_Jha_52506's avatar
    Nov 28, 2017

    If string position is known then you can use

    getfield
    function to grep value like below.

    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.