Wednesday, October 24, 2012

Tips on BigIP iRule to Filter Certain Urls

We have requirement to redirect certain urls to another website, here are example of how to deal with it on F5 Bigip iRule

Case 1:
 Any urls contains below 3 strings will be redirected
 "/content/idcplg/webdav*"     "/_dav/content/idcplg/webdav*"   "/*sscontributor=true*"

.....
else {
         switch -glob [string tolower [HTTP::uri]] {
            "/content/idcplg/webdav*" -
            "/_dav/content/idcplg/webdav*" -
            "/*sscontributor=true*"  {
               HTTP::redirect "http://our-stage.testadc.com/"
               event disable all
            }
...


Case 2:
Detect if  cookie wcm.contributor.mode exists and value is true, we  redirect urls
.......
elseif { [HTTP::cookie value "wcm.contributor.mode"] eq "true"  } {
         HTTP::redirect "http://our-stage.testadc.com/"
         event disable all
      }
......

Case 3:
Detect if  cookie wcm.contributor.mode exists and value is true, we remove the cookie
.....
elseif { [HTTP::cookie value "wcm.contributor.mode"] eq "true"  } {
          HTTP::cookie remove wcm.contributor.mode
                      }

Case 4
Any urls from right contains "?SSContributor=true" . It will be trimmed
As "?" is special character, we need to trim twice
.....
"/*sscontributor=true*" {
               HTTP::redirect [string trimright [string trimright [HTTP::uri] "SSContributor=true"]  \?]
.....

No comments: