Forum Discussion
mfkk531_168091
Apr 17, 2015Nimbostratus
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 req...
- Apr 18, 2015
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]" } }
mfkk531_168091
Nimbostratus
I get the following error
01070151:3: Rule [/Common/iRule_BrandingBrand_Redirect_IVD] error: /Common/iRule_BrandingBrand_Redirect_IVD:2: error: [missing a script after "if"][]
/Common/iRule_BrandingBrand_Redirect_IVD:4: error: [parse error: PARSE syntax 205 {syntax error in expression "[URI::query [HTTP::uri] MobileOptOut] eq 1]": extra tokens at end of expression}][{[URI::query [HTTP::uri] MobileOptOut] eq 1]}]
/Common/iRule_BrandingBrand_Redirect_IVD:14: error: [command is not valid in the current scope][}]
Kevin_Davies_40
Apr 18, 2015Nacreous
Was missing a opening brace at the end of the first if statement. You will need to test it though to make sure it meets your needs. You may want to consider lowercasing the HTTP::path to ensure it matches the strings.
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