Forum Discussion

jaddie_85451's avatar
jaddie_85451
Icon for Nimbostratus rankNimbostratus
Oct 22, 2014

User Agent Browser Rediret not working

Sorry for another browser user agent post..

I have this written this iRule and it is appears not to be working, it blocks the first line only and when I switch the order firefox with msie 8.0 it blocks all of ie.

Any suggestions why this would not be working or a better way to do this....

Thanks -Steve

when HTTP_REQUEST {

 Check if the client is an firefox browser 
if {[string tolower [HTTP::header value User-Agent]] contains "msie 8.0"}{ 
       HTTP::respond 302 Location "https://company.sharepoint.com/Help/Pages/Supported-Browsers.aspx" 
    } elseif { [string tolower [HTTP::header value User-Agent]] contains "firefox"} {
       HTTP::respond 302 Location "https://company.sharepoint.com/Help/Pages/Supported-Browsers.aspx" 
    } elseif { [string tolower [HTTP::header value User-Agent]] contains "msie 9.0"} {
       HTTP::respond 302 Location "https://company.sharepoint.com/Help/Pages/Supported-Browsers.aspx" 
    } elseif { ( [HTTP::cookie exists SITEA] ) } {
        HTTP::respond 302 Location https://company.sharepoint.com[HTTP::uri]
    } else {
        HTTP::respond 302 Location "https://spo.xyzapps.com/Help/Communication/LoginExperience/Internal/Internal_1.html" "Set-Cookie" "SITEA=1;path=/"
}
}

4 Replies

  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus

    Could you clarify what is happening a bit? When you say "block", do you mean that a redirect is sent to the client?

    Also, what do you mean by "blocks the first line"?

    Perhaps you can indicate what happens for the various browsers you're testing with?

    Also, if may help if you write some trace info to the log, e.g.:

    log local0.debug "Match for firefox"

  • Thanks for the reply:

     

    Yes I meant redirect, basically what happens is that if I put firefox in the first if statement it redirects as anticipated but not to any other browser type specified below in the elseif ...if I put MSIE 8.0 is the first statement it redirects all IE versions of browsers not just 8 or 9.

     

    So two problem I guess. 1. Does not seem to want to go to next if statement 2. Does not seem to want recognize the IE version type

     

    I guess I am looking for a better way to do this and very my agent definition statement

     

    Thanks again.

     

  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus

    Have you checked the values of User-Agent that are used by the browsers?

    log local0.debug [HTTP::header User-Agent]

  • Thank you both for your assistance, with your help I figured out what the issue was, the IE browser was being represented as a different version number due to Comparability (which I was assured was not being used) - my bad on assuming.

    Anyway we figured it out and in the process used the following iRule.

    Thank you both for your assistance

    when HTTP_REQUEST {
         Check the user agent
        if { ( [class match [string tolower [HTTP::header User-Agent]] contains useragentstoredirect]) }{ 
                                        HTTP::respond 302 Location "https://company.sharepoint.com/Help/Pages/Supported-Browsers.aspx" 
            } elseif { ( [HTTP::cookie exists SITEA] ) } {
                HTTP::respond 302 Location https://company.sharepoint.com[HTTP::uri]
            } else {
                HTTP::respond 302 Location "https://spo.companyapps.com/Help/Communication/LoginExperience/Internal/Internal_1.html" "Set-Cookie" "SITEA=1;path=/"
        }
        }
    
        useragentstoredirect = data group list