Forum Discussion

Hudson_Donovan_'s avatar
Hudson_Donovan_
Icon for Nimbostratus rankNimbostratus
Jun 28, 2006

Redirection based on URI - should be simple

Hi there,

 

 

This is my first post and I am a new user to Big-IP and the rules.

 

 

I have a task of creating a redirection rule that passes the URI to a different host domain.

 

 

I have written code that somehow doesnt seem to work and was wondering if people could advise me where I have gone wrong.

 

 

 

the senario is this..

 

 

if the url is www.ourdomain.com.au we just want the page to load as www.ourdomain.com

 

 

however if the url is www.ourdomain.com.au/12345 then we need to redirect to

 

www.differentcompanydomain.com/12345

 

 

where 12345 is a uri that changes all the time.

 

 

ive managed to get the first part working.. but the second part wont. can anyone assist.

 

 

----------------------------------------------

 

if (http_uri matches_regex "/") {

 

redirect to "http://www.ourdomain.com"

 

}

 

else {

 

redirect "http://www.differentcompanydomain.com(http_uri)"

 

}

 

 

Thanks in advance.

 

Hudson
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    Try this ("equals" is a more efficient comparison than "matches_regex"):
    if (http_uri == "/") {
      redirect to "http://www.ourdomain.com"
    } 
    else {
      redirect to "http://www.differentcompanydomain.com/%u"
    }

    HTH

    /deb
  • Cheers,

     

     

    I have managed to get this to work, the final code was

     

     

    if (http_uri == "/") {

     

    redirect to "http://www.ourdomain.com"}

     

    else {

     

    redirect to "http://www.differentcompanydomain.com" + http_uri

     

    }

     

     

     

    Thanks for your assistance.

     

     

    Hudson