Forum Discussion
Michael_Yates
May 13, 2010Nimbostratus
From what you are trying to do with your iRule, you shouldn't need to put the [HTTP::uri] or [HTTP::path] into a variable unless you are doing something else that you didn't include in your post. The F5 is already doing that for you with these two iRule Variables ([HTTP::uri] and/or [HTTP::path]).
Try this and see if it works better for you:
- I didn't include the target="_blank", so you can add that back in if you want the redirect to open in a new browser.
when HTTP_REQUEST {
if { [HTTP::host] equals "www.somesite.com" } {
HTTP::redirect "http://somedifferentsite.com"
}
if { [ string tolower [HTTP::uri]] equals "/url1" or [ string tolower [HTTP::uri]] equals "/url2" } {
HTTP::redirect "http://[HTTP::host]/url2"
}
elseif { [ string tolower [HTTP::uri]] starts_with "/images" } {
HTTP::redirect "http://legacy.somesite.com[HTTP::uri]"
}
}
You could also do it this way:
when HTTP_REQUEST {
if { [HTTP::host] equals "www.somesite.com" } {
HTTP::redirect "http://somedifferentsite.com"
}
switch -glob [ string tolower [HTTP::uri]] {
"/url1*" -
"/url2*" { HTTP::redirect "http://[HTTP::host]/url2" }
"/images*" { HTTP::redirect "http://legacy.somesite.com[HTTP::uri]" }
}
}
The dash on the end of the ( "/url1*" - ) statement tells it to follow the same action as the next statement, so in this case it will follow the same action as the "/url2*".