cancel
Showing results for 
Search instead for 
Did you mean: 

irule for redirection

Rohan
Nimbostratus
Nimbostratus

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 4

Samir
Nacreous
Nacreous

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

why it will not work, Any specific reason ?

Samir
Nacreous
Nacreous

Is it working for you? Did you check? Always connection go here.

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

You need to modify iRule.​

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