Forum Discussion

Sabir_Alvi's avatar
Sabir_Alvi
Icon for Altocumulus rankAltocumulus
Mar 08, 2018

iRule redirect to https if condition doesn't match

I need to send traffic to appr pools on port 80 based on a specific Host and URI combination and all other traffic should get redirected to https irrespective of Host and URI combination. I have below iRule that works fine for my port 80 work. Please suggest what to append to redirect traffic to https otherwise. Redirect to https should be based on [HTTP::host]

when HTTP_REQUEST {
    switch -glob [HTTP::host][HTTP::uri] {
    "sample1.ehosts.net/word1/word2*" { pool sample1.ehosts.net_word }
    "sample2.ehosts.net/word1/word2*" { pool sample2.ehosts.net_word }
    "sample3.ehosts.net/word1/word2*" { pool sample3.ehosts.net_word }
   }
}
  • You may add the

    default
    Condition

    when HTTP_REQUEST {
        switch -glob [HTTP::host][HTTP::uri] {
        "sample1.ehosts.net/word1/word2*" { pool sample1.ehosts.net_word }
        "sample2.ehosts.net/word1/word2*" { pool sample2.ehosts.net_word }
        "sample3.ehosts.net/word1/word2*" { pool sample3.ehosts.net_word }    
        default {     
             add the action here       
        }
       }
    }