homer_simpsonSometimes a people just make things harder than they have to be.  Myself included unfortunately.  Not long ago, I was given the task to write an iRule that would scan the URL of an incoming HTTP request and redirect it to a new location.  No problem right?  I have done that a million times as I am sure most of you out there have as well.  Here’s the catch.  It turns out I would need to scan the URL for a value that was NOT there.

Now this was an afront to my logic!  My brain was so used to thinking “If this, then this”, that it really was hard for me to wrap my brain around how I was going to pull this off.  So of course, I did what any sane F5’er does when he is looking for an answer to a puzzle he cannot solve.  I turned to Devcentral and the community forums.  I dug around for a while and eventually I found an old 4.0 iRule where an individual had used the “not” Logical Operator.

So I gave myself a big slap on the forehead and muttered a Homer Simpson’ish “DOH!!”.  I later went on to discover that the “not” Logical Operator is well documented on DevCentral here.  Below is the simple iRule that has saved our company thousands of dollars, saved the help desk many man hours of labor, prevented users from going insane because of broken links and keeps things simple.  It is amazing how an iRule so simple, can have such a dramatic impact.  So, the next time you are writing an iRule, just think of all the things you could “NOT” be doing!

if { not ([string tolower [HTTP::host]] contains ".mycompany.com")}{
HTTP::redirect "https://[HTTP::host].mycompany.com[HTTP::uri]"


6 comments so far

Add Your Comment
  1. Nice blog.

  2. Many thanks!

  3. Just what i was looking for – Thanks! Neat Blog.

  4. Still usefull ;-)


  5. NOT(useless)

  6. Thanks, been battling with something similar for a while now, gave me a nudge in the right direction.