F5 is upgrading its customer support chat feature on My.F5.com. Chat support will be unavailable from 6am-10am PST on 1/20/26. Refer to K000159584 for details.

Forum Discussion

KimiLi_147173's avatar
KimiLi_147173
Icon for Nimbostratus rankNimbostratus
Nov 26, 2017
Solved

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 27, 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.