Showing results for 
Search instead for 
Did you mean: 
Login & Join the DevCentral Connects Group to watch the Recorded LiveStream (May 12) on Basic iControl Security - show notes included.

iRules appending after url


Hello F5 !!!


I am newbie in the world of load balancing, apologies if I am posting a silly question.


Recently I have published a https website, created a iRule to redirect from http to https using below


when HTTP_REQUEST { if {[HTTP::host] equals ""} { HTTP::redirect https://[HTTP::host][HTTP::uri] } else { HTTP::redirect "[HTTP::uri]" } }


Now I have a requirement to append a string after the url, example if some user is visiting, he should be redirected to


Thanks in advance.


try this irule   when HTTP_REQUEST {   if { ([HTTP::host] == "") and ([HTTP::uri] == "/*") } {   HTTP::redirect https://[HTTP::host][HTTP::uri]   }   elseif { ([HTTP::host] == "") } {   HTTP::redirect https://[HTTP::host]/something   }   }


Hello Ragu,


When I tried, recieving below error,


01070151:3: Rule [/Common/] error: /Common/ error: [undefined procedure: elseif][elseif { ([HTTP::host] == "") } {   HTTP::redirect https://[HTTP::host]/something   }]




Generic http to https redirect, retaining the original URI of the request for http virtual server:

when HTTP_REQUEST { HTTP::respond 301 Location "[HTTP::uri]" }



https redirect to default page within https, for https virtual server:

when HTTP_REQUEST { if { [HTTP::path] equals "/"} { HTTP::respond 301 Location "" } }


Just to summarize, so I have to create two irules, one for the redirection of http traffic to https and other for adding "/something" at the end of the URL.

The iRule for the http virtual server will cover the redirects to https for all requests. That will help mitigate situations like if someone forgets to type https on their browser. Without it they would get a timeout.

The iRule for the https virtual server will simply make sure that if someone types the URL, they get redirected to the website's initial landing/login page. For example, if someone types '', without the iRule they would be sent to the default setup on the servers. If you don't have any programing on the servers to redirect requests to path '/' to the initial login page '/web/login.php'. With the iRule the F5 will make sure that requests to the default path '/' get redirected to '/web/login.php', while leaving requests to any other paths intact.


please try the below irule

when HTTP_REQUEST {   HTTP::redirect https://[HTTP::host]/something   }





Nope Mazhar, unfortunately it's not working.


It's redirecting http request to https, however it's not appending /something.