Forum Discussion
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"}
}
}
- Colin_Walker_12Historic F5 AccountTry this:
when HTTP_REQUEST { if {([class match [string tolower [HTTP::header User-Agent]] contains "mobiledevices"]) && !([string tolower [HTTP::uri]] starts_with "/mobile")} { HTTP::redirect "http://[HTTP::host]/mobile"} }
- collinz1_17223NimbostratusThat works perfectly, exactly what i needed.
- Colin_Walker_12Historic F5 AccountGlad to hear it. :)
- Ashish_Ram_Tak1NimbostratusDear Colin,
- rajeshramhit_11NimbostratusHi,
- Ashish_Ram_Tak1Nimbostratushow should i do that
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