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

Ahmadj_283318's avatar
Ahmadj_283318
Icon for Nimbostratus rankNimbostratus
Aug 25, 2016

Redirect many domains

Hi

 

I am trying to create an iRule to:

 

redirect (www.x.com to www.x.com/a/b/c)

 

and

 

redirect (www.y.com to www.y.com/w/d/r)

 

and

 

redirect any (a.com/z/v to domain.com)

 

also redirect (a.com/z/v/p to a.com/z/v/p)

 

Thank you for help..

 

4 Replies

  • You can use switch statement to perform the redirects.

     

    OR

     

    You can utilize data group and class match statements.

     

    See if this link helps.

     

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    Are you sure about this, redirecting to itself?

    also redirect (a.com/z/v/p to a.com/z/v/p)

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus
    when HTTP_REQUEST {
        switch -- [string tolower [HTTP::host]] {
            "www.x.com" {
                HTTP::redirect "https://www.x.com/a/b/c/"
            }
            "www.y.com" {
                HTTP::redirect "https://www.y.com/w/d/r/"
            }
            "a.com" {
                if { [HTTP::uri] starts_with "/z/v/p" } {
                    HTTP::redirect "https://domain.com/z/v/p"
                } elseif { [HTTP::uri] starts_with "/z/v" } {
                    HTTP::redirect "https://a.com/"
                }
            }
        }
    }
    
  • Why not using policies. These are available starting 11.4 and are more efficient than iRule in this case. see here for details:

     

    https://support.f5.com/kb/en-us/solutions/public/15000/000/sol15085.html