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 we take a look at a couple of simple commands that can make your life a lot easier. iRules don't have to be complex to be useful, as such it's a good notion to make yourself familiar with some of the basic commands and the many ways in which they can be utilized as often times you'll find that the complex problem you're trying to solve isn't quite as complex as you think. This week we've got some good examples of exactly that.

URI Splicing


In this example user rogerluo was looking to insert a new portion of a URI, in this case a static folder structure, into the beginning of any inbound HTTP request. There are a couple of ways that this could work, but it's actually very simple with an if statement and the HTTP::redirect command. That is, of course, assuming you want to issue a full fledged client side redirect. You could also use the HTTP::uri command to just subtly update the URI on the way to the server, but I'll leave that up to you.