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

Koalan's avatar
Koalan
Icon for Cirrus rankCirrus
Jun 18, 2020

iRule for redirection

Hi,

 

I am not really familiar with iRule, can somebody help me?

 

So the scenario is that a user wants to access a f5 vip which will be redirected to a certain site:

 

user access onboarding.abc.com/uk (f5 vip) and it should redirect to https://ask.service.com/management.do

 

how can i attain this? it's needs to be exactly as onboarding.abc.com/uk

 

Thanks!

5 Replies

  • Hello  ,

     

    You can even achieve your requirement using LTM Policy option. Also you can try below iRule.

     

     when HTTP_REQUEST {

    if { [HTTP::host] contains "onboarding.abc.com"}{

    if { [HTTP::uri] starts_with "/uk"}{ 

    HTTP::redirect https://ask.service.com/management.do

    }

    }

     

    Hope it works!

    Mayur

     

  • Policy is always a better choice. I agree with  's iRule. Small correction needed; There is no points to add multiple if condition. Find the below iRule, Hope it will work for you.

    when HTTP_REQUEST {
    	if { ([HTTP::host] equals "onboarding.abc.com") && ([HTTP::uri] starts_with "/uk") } {
    		HTTP::respond 301 Location "https://ask.service.com/management.do"
    	}
    }
  • btw whats the difference between that HTTP::respond 301 to the normal redirect ?

  • HTTP::redirect:- This command always sends an HTTP 302 (Temporary Redirect) status code. HTTP request to the specified URL, or replaces the current response with a redirect to the specified URL.

     

    HTTP::respond:- This command sends a response to the client telling the client to send a fresh request to the URL you specify. A 301 redirect means that the page has permanently moved to a new location.