Forum Discussion

Ravi_110217's avatar
Ravi_110217
Icon for Nimbostratus rankNimbostratus
Mar 11, 2008

HTTP page redirection request

Hello Guys,

 

 

I wonder if someone could help me with following web page redirection rule. I am not much more familiar with F5 product, please help me out with my following request.

 

I want to redirect one of our web page... example,

 

 

www.abc.com.au to

 

www.abc.com.au/abconline/HomePage.aspx

 

 

I have written following irule but does not seem to be working for me.

 

 

when HTTP_REQUEST {

 

if { [HTTP::host] equals "www.abc.com.au" }

 

{

 

HTTP::redirect "http://www.abc.com.au/abconline/HomePage.aspx"}

 

}

 

 

 

I'm using following IOS on my F5:

 

BIG-IP 9.3.0 Build 187.3...

 

 

 

Hope to hear soon.

 

Ta,

 

 

 

4 Replies

  • The problem with your iRule is that it will lead to an infinite loop. The redirect will go back into the iRule and, since the host is the same, it will issue the redirect again. You'll want to add a check to see if the URI is blank before issuing the redirect. I'm also not sure what's up with the close curly brace after your HTTP redirect statement. That should go too...

    This should do the trick for you:

    when HTTP_REQUEST {
      if { ([HTTP::host] eq "www.abc.com.au") && ([HTTP::uri] eq "/") } {
        HTTP::redirect "http://www.abc.com.au/abconline/HomePage.aspx"
      }
    }

    Now, if your virtual is only hosting the www.abc.com.au domain and no others, then you can remove the first comparison and just have the URI check. But, if it's hosting multiple domains and you only want the redirect for when the host AND uri match this condition, leave it as is.

    -Joe
  • Joe,

    From an evaluation and executuion perspective

    
     ([HTTP::host] eq "www.abc.com.au") && ([HTTP::uri] eq "/")

    Will the iRULE interpreter evaluate the first argument and if it's false will stop there or will it continue to evaluate the second argument?

    CB

  • I don't know for a fact since I haven't tested it, but any language worth anything would not evaluate and expressions if they have no consequence. If you are really worried about it, you could always use nested ifs.

     

     

    -Joe
  • The idea I was toying around with is basically trying to increase the performance to evaluation. I know that Perl does this, but wasn't sure if iRULE did the same.