mfkk531_168091
Apr 17, 2015Nimbostratus
Solved
Question on Redirect to mobile website - plz help
I have been given an old iRule to implement now to redirect to mobile site. But i suspect there is some syntax errors. Can someone help me check the rule and see if its good, and will work for my requirement.
when HTTP_REQUEST {
if { [matchclass [HTTP::header User-Agent] contains $::abcd_useragents] } {
if { [URI::query [HTTP::uri] "MobileOptOut"] ne 1 && [HTTP::cookie MobileOptOut] ne 1} {
if { not ([HTTP::uri] ends_with "jpg" ||
[HTTP::uri] ends_with "gif" ||
[HTTP::uri] ends_with "png" ||
[HTTP::uri] ends_with "bmp" ||
[HTTP::uri] ends_with "ico") } {
HTTP::redirect "http://m.xyzdomain.com[HTTP::uri]"
}
}
}
}
Thanks
Had an extra ] at the end of the third if statement. This should fix it for you.
when HTTP_REQUEST { if {[class match [HTTP::header User-Agent] contains abcd_useragents] } { if {[HTTP::cookie MobileOptOut] eq 1} { return } if {[URI::query [HTTP::uri] MobileOptOut] eq 1} { return } switch -glob [string tolower [HTTP::path]] { "*.jpg" - "*.gif" - "*.png" - "*.bmp" - "*.ico" { return } } HTTP::redirect "http://m.xyzdomain.com[HTTP::uri]" } }