Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

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 }
   }
}
0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

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       
    }
   }
}
0
Comments on this Answer
Comment made 08-Mar-2018 by Sabir Alvi 75

Thanks, added a redirect as default and it worked as expected.

0