For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Aviv's avatar
Aviv
Icon for Cirrus rankCirrus
Feb 18, 2016

IE user agent

Hi!

 

i have an app that support only IE. i want to display a some message to all browsers except IE. i have found that only IE have a user agent string that contains "Trident". how to write an irule that redirect any except user agent that contains "Trident"?

 

Thanks,

 

Aviv Hassidim

 

I have this irule that open a message page only to user agents that contains some string:

 

when RULE_INIT { set static::refresh_time 15 set static::notification_page {

 

System Notification

You are using an unsupported browser and will be redirected to Myspace.com

 

Wait $static::refresh_time seconds to continue, or click

 

} } when HTTP_REQUEST { switch -glob [ string tolower [HTTP::header User-Agent]] { "msie 10.0" - "msie 9.0" - "msie 8.0" - "msie 7.0" - "msie 6." { HTTP::respond 200 content [subst $static::notification_page] Mime-Type "text/html" log local0. "Client IP:[IP::client_addr] has been redirected with user agent :[HTTP::header User-Agent]" } default { go to a default location if nothing matches } } }

 

3 Replies

  • Josiah_39459's avatar
    Josiah_39459
    Historic F5 Account

    Change this part:

     

    "switch -glob [ string tolower [HTTP::header User-Agent]] { "msie 10.0" - "msie 9.0" - "msie 8.0" - "msie 7.0" - "msie 6." {"

     

    to

     

    if { !([string tolower [HTTP::header User-Agent]] contains "trident") } {

     

    • Aviv's avatar
      Aviv
      Icon for Cirrus rankCirrus
      Hi Josiah! i get : error: [command is not valid in the current scope][}] when i replace as u suggested...
  • Ok! Now is works. This Irule will search for trident is the http request and if there is no such a string it will show an html page with a message that not ie browser is not supported. enjoy!

    when RULE_INIT { set static::refresh_time 30 set static::notification_page {

    BODY {text-align: center}

    <h3>Open This Site Only in IE</h3>
    `
    
    
    
    
    
    
    <font color="DarkSlateBlue"    
    
    Thanks
    
    <font color="Teal"     
        **IT Team**
    
     } 
     }
     when HTTP_REQUEST {
    if { !([string tolower [HTTP::header User-Agent]] contains "trident") } {
        HTTP::respond 200 content [subst $static::notification_page] Mime-Type "text/html"
          log local0. "Client  IP:[IP::client_addr]  has been redirected with user agent :[HTTP::header User-Agent]"
        } 
    else {
    
    `}
    

    }