Forum Discussion

SAM2_121342's avatar
SAM2_121342
Icon for Nimbostratus rankNimbostratus
Nov 24, 2014

Redirect iRule that includes Operating System?

Hi - I'm working on building my first iRule for my LTM's. We want to redirect users based on user agent header info but along with the type of browser we want to also specify the users OS. I see the agent header info should have this data - "msie 8.0; windows nt 5.1" is anyone else doing this? Is this possible to accomplish without redirecting everyone using "MSIE 8.0" - only users with Windows XP?

 

An example of what I have put together:

 

when HTTP_REQUEST { if { [string tolower [HTTP::host][HTTP::uri]] contains "www.newsite.example.com" } { switch -glob [string tolower [HTTP::header User-Agent]] { "windows nt 5.1" - "android 2.3" { HTTP::redirect "http://www.browser-OS-refused.example.com" } } } }

 

  • you should be able to use nested IFs to accomplish your redirect or something like:

    when HTTP_REQUEST {
        if { [string tolower [HTTP::header User-Agent]] contains "windows nt 5.1"  && [string tolower [HTTP::header User-Agent]] contains "msie 8.0"}{
            HTTP::redirect "http://www.browser-OS-refused.example.com"
        }
    }
    
  • you should have to add special sequences (e.g. asterisk) in switch pattern (since it is not exact match).