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_REQUEST {
if { !([HTTP::uri] contains "requestAgent") }
{
if { [matchclass [HTTP::header "User-Agent"] contains $::MobileAgents] }
{ HTTP::redirect https://[HTTP::host]/[HTTP::uri]?requestAgent=mobile}
}
}
it looping, keep adding string at the end, how can i stop it.
thanks
- naladar_65658AltostratusIt sounds like your request matches the code in the iRule, it is then being redirected back out, the request then comes in again, triggers the iRule and like you said just continues to loop. You need to introduce some logic there that breaks that, either by sending it to a pool of web servers or redirecting it somewhere will it will not come back through that same iRule.
- dlg_23340Cirrusnaladar, he has the right idea, that's the first if statement - !([HTTP::uri] contains "requestAgent") - note the !.
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" } } }
- dlg_23340CirrusOK, that last bit of irule, i added a ! for some other testing. Editing is apparently out of the question here, so here is the irule as I reformatted it. Ignore what I posted above.
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" } } }
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