collinz1_17223
Jul 14, 2011Nimbostratus
iRule Redirect Loop
I have setup an irule that checks the user agent string when http requests are made. If the user agent is a mobile type device (as defined in a data group) they get redirected to the mobile site.
when HTTP_REQUEST {
if {[class match [string tolower [HTTP::header User-Agent]] contains "mobiledevices"]} {
HTTP::redirect ""}
}
The issue is that i am get redirect loop errors. Reason being is that the user is being redirected to the same host but a different URI. This means that they are using the same VIP and the irule is being matched again.
I thought of adding in an addition if statement to check the URI (below) but i can't seem to get it to work. Any help would be greatly appreciated.
when HTTP_REQUEST {
if {[HTTP::uri] starts_with "/mobile"} {
return
if {[class match [string tolower [HTTP::header User-Agent]] contains "mobiledevices"]} {
HTTP::redirect "http://[HTTP::host]/mobile"}
}
}