Forum Discussion

Edu_50128's avatar
Edu_50128
Icon for Nimbostratus rankNimbostratus
Apr 06, 2011

URL redirect

Hello,

 

 

I´m new in iRules...

 

 

I need to configure F5 to redirect a URL... so it is, I need to redirect the traffic for the url www.mypage.com to www.newpage.com, but the last one is not on my network, it´s on a web hosting (first one yes).

 

 

I´ve thought this configuration:

 

 

when HTTP request {

 

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

 

HTTP: redirect "http://www.newpage.com"

 

}

 

}

 

 

Will it work? What dou you think?

 

 

Is there any other configuration better?

 

 

thanks

 

 

best regards

 

 

 

  • Yes. That will work and result in a 302 Temporary Redirect.

    You can send a 301 Permanent Redirect using HTTP::respond if you prefer.

    
    when HTTP_REQUEST {
    if { [HTTP::host] equals "www.mypage.com" } {
    HTTP::respond 301 Location "http://www.newpage.com"
    }
    }
    
  • The [HTTP::host] portion of any URL should be auto case insensitive on any platform. Its the [HTTP::uri], [HTTP::path], or [HTTP::query] portions that are case sensitive.
  • That will teach me to skim through a post on my phone, no uri in his post ;) Thanks for the catch.

     

     

    @edu, It makes no difference if the server is local or remote, you're providing the redirect . The host will receive the redirect, lookup the new name, the authoritve name server will respond with resolved IP then host will attempt to route to that new IP.