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

Rohan's avatar
Rohan
Icon for Nimbostratus rankNimbostratus
Apr 02, 2020

irule for redirection

I have below requirement and and I have draft below iRule, Will it work ?

a. If user try to access http://abc.com/ or http://10.10.10.10/ redirects to https://www.abcworld.com/

b. If user try to access http://abc.com/* or http://10.10.10.10/* redirects to https://www.abc.com/*

Note: * is means any uri.

abc.com = 10.10.10.10

www.abcworld.com = 1.2.3.4

www.abc.com = 5.6.7.8

 

when HTTP_REQUEST {

if { (([string tolower [HTTP::host]] eq "abc.com") || ([HTTP::host] eq "10.10.10.10")) && ([HTTP::uri] eq "/") } then

  {

    HTTP::redirect "https://www.abcworld.com/"

  }

 elseif { ([string tolower [HTTP::host]] eq "abc.com") || ([HTTP::host] eq "10.10.10.10") } then

  {

HTTP::redirect "https://www.abc.com[HTTP::uri]"

}

else {

    

  }

}

4 Replies

  • This will not work. Go to devcentral iRule syntex and try once again.

    • Rohan's avatar
      Rohan
      Icon for Nimbostratus rankNimbostratus

      why it will not work, Any specific reason ?

    • Rohan's avatar
      Rohan
      Icon for Nimbostratus rankNimbostratus

      Its Worked, There is and clause in irule, so first Condition will only hit when URL is abc.com/ or abc.com and 2nd Condition will hit when request URL is abc.com/test