Posted By dsirrine@gmail.com on 02/17/2009 1:45 PM
I've got what would seem to be a simple redirect:
I'm trying to take any requests bound for:
http://ads.xyz.com/
and redirect them to:
https://ads.xyz.com/some/stuff.do
The rule I put up was this:
if { [HTTP::host] equals "ads.xzy.com"} {
HTTP::redirect "https://[HTTP::host]/some/stuff.do:443"
}
but when I watch it through wireshark it just loops endlessly (because the redirect matches the rule itself?)
Can someone help out an F5 newb?
Thanks.
Well the reason for this is that the "Host" will always be "ads.xyz.com", So every time, it checks this condition, it returns a true and thus the redirect happens.
You can actually verify this on the Wireshark by looking for HTTP 302 packets, you will see the Server name as "BigIP" or a variant of this, so we can be sure that the big IP is redirecting and not the page.
So you have to use the below code
if { ([HTTP::host] equals "ads.xyz.com") and ([HTTP::uri] equals "/") } {
HTTP::redirect "https://[HTTP::host]/some/stuff.do"
}
This is a very simple solution, you have to note this point that a lot of URI always end with a "/", so we need to make a perfect match and so you have to use the keyword "equals"
Also, if you want to have a multiple redirect for the same host, you can use a nested loop
if { ([HTTP::host] equals "ads.xyz.com") {
if {[HTTP::uri] equals "/"} {
HTTP::redirect "https://[HTTP::host]/some/stuff.do"
}
}
You can actually add a lot of other else if in the inner loop to redirect other pages also.
Hope this helps