What could you do with your code in 20 Lines or Less? That's the question I ask (almost) every week for the devcentral community, and every week I go looking to find cool new examples that show just how flexible and powerful iRules can be without getting in over your head.

This week I do the unthinkable ... I write my own code! Well, some of it, anyway. While I've been happily using the community's examples for this series this week I ended up writing a couple of neat 20LoL worthy entries as responses to forum posts, so I figured I'd give the rest of the community a breather from doing all my heavy lifting this week. Two of the examples are mine and the third is from Jason. You can tell which one is his, just look for the really wicked awesome one that I wish I had written.

On to the code!

Host Header Route and Re-write


First up is a request from user willko (please tell me your name is Roger, too perfect...) who is looking to combine two iRules into one that suits his needs. One iRule is performing a check against inbound hosts and routing to the appropriate node based on which host the request was sent to. The other is doing some header rewriting to make sure the extraneous characters get removed. Those two are definitely things that play well together, so I whipped up a little example using class and some fun scan magic to make it happen.