Forum Discussion
peter_56193
Jul 26, 2012Nimbostratus
irule to add string for mobile device
HI all, can some one have a look of my irule, try to add string if the request is from mobile device.
have setup data group MobileAgents contain mobile device key words.
when HTTP_REQUE...
dlg_23340
Aug 02, 2012Cirrus
naladar, he has the right idea, that's the first if statement - !([HTTP::uri] contains "requestAgent") - note the !.
peter, your irule worked for me, though I had to make a change to a bit of it.
when HTTP_REQUEST {
if { !([HTTP::uri] contains "requestAgent") } {
if { !([matchclass [HTTP::header "User-Agent"] contains $::MobileAgents]) } {
HTTP::redirect "https://[HTTP::host][HTTP::uri]?requestAgent=mobile"
}
}
}
I put quotes around the value after HTTP::redirect, and removed the / between [HTTP::host] and [HTTP::uri], as the URI will always at a minimum contain a /. In general this probably isn't very robust - imagine a user coming in on a mobile device with the url http://example.com/?foo=bar. Your irule will redirect them to http://example.com/?foo=bar?requestAgent=mobile, which will I suppose work for the irule but will confuse your application on the backend.
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