Forum Discussion

Jericho_Gutierr's avatar
Jericho_Gutierr
Icon for Nimbostratus rankNimbostratus
Apr 18, 2006

http redirect to https for same V-server

Hi -

 

 

I'm looking for a simple, elegant solution for this. I have the following existing iRule for https redirect for one client:

 

 

when HTTP_REQUEST {

 

if { [HTTP::host] ends_with "company1.mysite.com"} {

 

HTTP::redirect "https://[HTTP::host][HTTP::uri]"

 

}

 

}

 

 

I have several other hosts for the same V-server that need to do this as well. I know I can attach individual iRules for each host redirect, i.e. company2.mysite.com, company3.mysite.com, etc. However, is there a way to do this in one rule? My instinct was to do multiple if-else statements for each host in a single rule, but is that the way to go?

 

 

Thanks in advance,

 

- Jericho
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    What you'll probably want to do is create a data group that stores all of the hosts that you want to redirect. This way you can use the matchclass command to search through the class and determine whether or not the request should be redirected.

     

     

    There's a thread showing how the matchclass command can be used here: Click here

     

     

    For your purposes you should be able to create a data group with each host in it, and instead of directing to a specific pool if the matchclass command returns true, just perform the HTTPS redirect.

     

     

    HTH,

     

    Colin
  • Thanks! Worked like a charm. FYI, your reply came in a full HOUR ahead of my case with f5 tech support (and they directed me here anyway). Thanks again...

     

     

    - Jericho