Forum Discussion

Adam_Fint_1489's avatar
Adam_Fint_1489
Icon for Nimbostratus rankNimbostratus
Oct 04, 2011

splitting a domain apart; can I used awk in an iRule?

Our Marketing department went out and purchased hundreds of domains names in the format of xxxcompany.com, such as:

 

 

applecompany.com

 

bananacompany.com

 

picklecompany.com

 

 

They want these to point to a VIP, and have the F5 do a 301 to:

 

 

applecompany.com -> apple.company.com

 

bananacompany.com -> banana.company.com

 

picklecompany.com -> pickle.company.com

 

whatevercompany.com -> whatever.company.com

 

 

I don't know the business case, but this is what they want.

 

 

Can I use awk in an iRule to split the HTTP::host apart?

 

 

2 Replies

  • Hi Adam,

     

     

    No, you can't use awk from an iRule. But you can use string functions or a regex to do this. You could use the getfield string function for this to avoid the overhead of a regex:

     

     

    set subdomain [getfield [HTTP::host] "company.com" 1]

     

    HTTP::replace Host "$subdomain.company.com"

     

     

    For details on the getfield command, you can check the wiki page:

     

    http://devcentral.f5.com/wiki/iRules.getfield.ashx

     

     

    Aaron