Forum Discussion
Damien_Turner_1
Nimbostratus
Aug 02, 2010Redirect if your a mobile user....
Hi all, I was wondering if I could have some help!
I have been asked if it is possible to use an iRule to redirect a mobile user to a new URL.
An example would be....
user on an iPhone goes to www.m...
Damien_Turner_1
Nimbostratus
Aug 04, 2010Hi Aaron thank you for helping me again, I have made the changes so my rule now looks like this....
when HTTP_REQUEST {
if { [HTTP::header "User-Agent" ] contains $::MobileUserAgents } {
HTTP::redirect "http://mobile.holidayextras.co.uk[HTTP::uri]"
log local0. "iPhone Found"
}
Uncomment the line below to turn on logging.
log local0. "Mobile Redirected: [HTTP::header "User-Agent"] -Phone Redirected"
}code]
My DataGroup is a string with....
*iPhone*
*iPad*
*iPod*
I like My Apple stuff!
But the iRule dosn't seem to be working as nothing is being written to the log, if I turn on the global log I can see iPhone user agents passing through....
Aug 4 09:33:17 tmm tmm[1800]: Rule Mobile_UserAgent_Redirect_iRule : Mobile Redirected: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) -Phone Redirected
Aug 4 09:33:17 tmm tmm[1800]: Rule Mobile_UserAgent_Redirect_iRule : Mobile Redirected: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) -Phone Redirected
Aug 4 09:33:17 tmm tmm[1800]: Rule Mobile_UserAgent_Redirect_iRule : Mobile Redirected: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) -Phone Redirected
Aug 4 09:33:17 tmm tmm[1800]: Rule Mobile_UserAgent_Redirect_iRule : Mobile Redirected: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) -Phone Redirected
Aug 4 09:33:17 tmm tmm[1800]: Rule Mobile_UserAgent_Redirect_iRule : Mobile Redirected: Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A306 Safari/6531.22.7 -Phone Redirected
Aug 4 09:33:17 tmm tmm[1800]: Rule Mobile_UserAgent_Redirect_iRule : Mobile Redirected: Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A306 Safari/6531.22.7 -Phone Redirected
Aug 4 09:33:17 tmm tmm[1800]: Rule Mobile_UserAgent_Redirect_iRule : Mobile Redirected: Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A306 Safari/6531.22.7 -Phone Redirected
Aug 4 09:33:18 tmm tmm[1800]: Rule Mobile_UserAgent_Redirect_iRule : Mobile Redirected: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) -Phone Redirected
I'm confused!
Also you said if I'm running 9.4.4 then I should remove the $:: from the datagroup, I have 9.4.8 HF4 running but it wont let me take out the $::, when I try and pass the rule through the irule editor it keeps telling me my irule is invalid.
Thank you for your help guys!Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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