Forum Discussion
Edu_50128
Nimbostratus
Apr 06, 2011URL 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
5 Replies
- Michael_Yates
Nimbostratus
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" } } - Edu_50128
Nimbostratus
Thanks a lot !!! - if you want a case insensitive match remember to use "string tolower"
- Michael_Yates
Nimbostratus
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.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects