If I may add, if I can impart any particular wisdom about iRules, it would be that
log local0. is your friend
There are a bunch of ways to troubleshoot iRules, but the above should be a poster that you hang on your wall. Using the log command
https://devcentral.f5.com/wiki/iRules.log.ashx
You can insert information into your code to show you what things look like at different stages, and what paths an iRule takes. Example:
when HTTP_REQUEST {
log local0. "Request URI is [HTTP::uri]"
switch [string tolower [HTTP::uri]] {
...
}
}
The above log statement will tell you what the user is requesting, which will make troubleshooting your switch statement easier. Anywhere you're not sure about what the iRule is doing, or what a variable might contain, drop in a log statement. Then from the command line, watch the iRule processing in real time:
tail -f /var/log/ltm
Just remember to remove/comment out your log statements before you put the iRule in production.