Forum Discussion

isavic's avatar
isavic
Icon for Nimbostratus rankNimbostratus
Dec 30, 2020

Irule redirect in F5 LTM

Hi,

I need to redirect this URI:

https://test.com/ibe/common/advancedCarSearch.do?changeLocale=en_CA to

https://www.test.com/en/travel/car-unavailable.html and

 

https://test.com/ibe/common/advancedCarSearch.do?changeLocale=fr_FR to

https://test.com/fr/voyages/voiture-indisponible.html

 

Is it possible to put evrything in one irule with if statement.

Thanks,

Igor

 

  • Dojs's avatar
    Dojs
    Icon for Cirrostratus rankCirrostratus

    I believe that something like below could help you:

     

    ltm rule locale_redirect {

    when HTTP_REQUEST {  

        if { ([string tolower [HTTP::uri]] eq "en_CA") } {

        HTTP::redirect "https://www.test.com/en/travel/car-unavailable.html"

        }   

       elseif { ([string tolower [HTTP::uri]] eq "fr_FR") } {

        HTTP::redirect "https://test.com/fr/voyages/voiture-indisponible.html"

        }

    }

    }

  • isavic's avatar
    isavic
    Icon for Nimbostratus rankNimbostratus

    Thanks dojs,

    I did something like this and it's working:

    when HTTP_REQUEST {

       if { [HTTP::path] equals "/ibe/common/advancedCarSearch.do" } {

          if { [HTTP::uri] contains "?changeLocale=en_CA" } {

             HTTP::respond 301 Location "https://www.test.com/en/travel/car-unavailable.html"

             return

          }

          if { [HTTP::uri] contains "?changeLocale=fr_FR" } {

       HTTP::respond 301 Location "https://www.test.com/fr/voyages/voiture-indisponible.html"

     

    }

    }

    }

    thanks for advice.

    Igor